Код: Выделить всё
def approximate_pi(n):
step = 1.0 / n
result = 0
for i in range(n):
x = (i + 0.5) * step
result += 4.0 / (1.0 + x * x)
return step * result
https://habr.com/ru/company/numdes/blog/581374/
Код: Выделить всё
def approximate_pi(n):
step = 1.0 / n
result = 0
for i in range(n):
x = (i + 0.5) * step
result += 4.0 / (1.0 + x * x)
return step * result