21 lines
502 B
Python
21 lines
502 B
Python
import math
|
|
|
|
|
|
def is_equal_to_with_digits(expected, actual, digits):
|
|
return round(expected, digits) == round(actual, digits)
|
|
|
|
|
|
expected_value = math.pi ** 2 / 6
|
|
|
|
n = 1
|
|
sum = 0
|
|
|
|
while not is_equal_to_with_digits(expected_value, sum, 6):
|
|
sum += 1 / n ** 2
|
|
n += 1
|
|
|
|
if n % 100000 == 0:
|
|
print(n, round(sum, 6), round(expected_value, 6), expected_value - sum)
|
|
|
|
print("result after", n, "iterations:", round(sum, 6), "; compare value:", round(expected_value, 6), expected_value - sum)
|