An open API service indexing awesome lists of open source software.

https://github.com/wuhan005/calculate-pi

A small program which use the ActionScript3 to calculate the PI
https://github.com/wuhan005/calculate-pi

Last synced: 8 months ago
JSON representation

A small program which use the ActionScript3 to calculate the PI

Awesome Lists containing this project

README

          

# Calculate-PI
A small program which use the ActionScript3 to calculate the PI

使用数学中的几何概形来计算圆周率。
具体思路就是随机生成点,然后依据点的(x,y)坐标来计算与圆心的距离,来判断是否落在圆内。

最初将times设置成与题目一样的1000次,得到结果为:3.188
并不是那么准确啊,接着不断把times增大,一直增大到播放器能承受的极限:99999999(虽然这不是CPU的极限,但是Flash播放器在计算超过15s后便会自动停止)

最后得出的结果:3.1416809514168094,大概范围在3.1414-3.1416之间。