Can someone explain to me the principle of calculating PI in this way and the three for statements

D2543691 注册会员
2023-01-25 20:02

Answer is not easy, answer useful please adopt, click on the right side of the answer to adopt!
This code is used to calculate PI. PI is an irrational number that can be approximated by an algorithm. This is a method called Mobius series.

The first for statement is to initialize the array f such that f[b] = a/5(where b is the loop variable and a is 10000).

The second for statement is the main loop, with c decreasing from 10000 to 5000. In each loop, by calculating the values of d and e, output the value of e+d/a and assign the value of e to d mod a.

The third for statement evaluates the values of d, f[b], and g in the second for statement. B from c, d + = f [b] a, [b] = d mod - g, f/d = g -, - b, d = b.

The output of this program is the approximate value of PI.

About the Author

Question Info

Publish Time
2023-01-25 20:02
Update Time
2023-01-25 20:02

Related Question

Intellij IDEA无法识别ant构建文件中的“扩展点”


执行npm install报错,怎么解决

JCIFS 报错transport closed in negotiate

r for data science学习



formcontrol setValue不会触发错误

Java编译错误:java: 需要class,interface或enum