mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-28 00:37:16 +00:00
17 lines
259 B
Plaintext
17 lines
259 B
Plaintext
def cpi(n)
|
|
i = 2
|
|
pi = 3
|
|
while i <= n
|
|
term = 4.0 / (i * (i + 1) * (i + 2))
|
|
if i % 4
|
|
pi = pi + term
|
|
else
|
|
pi = pi - term
|
|
end
|
|
i = i + 2
|
|
end
|
|
return pi
|
|
end
|
|
|
|
print("pi =", cpi(100))
|