2021-12-22 17:40:54 +01:00
|
|
|
sum := 0.0
|
|
|
|
k := 0
|
|
|
|
|
|
|
|
iterations := 100
|
|
|
|
|
2021-12-23 21:06:49 +01:00
|
|
|
while k < iterations {
|
2021-12-23 15:56:12 +01:00
|
|
|
k_f := float(k)
|
2021-12-23 16:51:10 +01:00
|
|
|
sum = sum + 1.0 / pow(16.0, k_f) *
|
|
|
|
(4.0 / (8.0 * k_f + 1.0) -
|
|
|
|
2.0 / (8.0 * k_f + 4.0) -
|
|
|
|
1.0 / (8.0 * k_f + 5.0) -
|
|
|
|
1.0 / (8.0 * k_f + 6.0))
|
2021-12-22 17:40:54 +01:00
|
|
|
k = k + 1
|
|
|
|
}
|
|
|
|
|
2021-12-25 12:45:27 +01:00
|
|
|
put("π ≈ ")
|
2021-12-26 10:55:31 +01:00
|
|
|
putln(sum)
|