repl.it
@imnotyouraura/

better pi approx

Python

nilakantha series

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
first_number = 2.0
second_number = 3.0
third_number = 4.0
pi_approx = 3.0
darts = int(input("how many darts to throw: "))
dartsThrown = 1
print(pi_approx)
for dartsThrown in range(1, darts):
  pi_approx = pi_approx + (4/(first_number * second_number * third_number))
  print(pi_approx)
  first_number, second_number, third_number, dartsThrown = first_number + 2, second_number + 2, third_number + 2,dartsThrown + 1
  pi_approx = pi_approx - (4/(first_number * second_number * third_number))
  print(pi_approx)
  first_number, second_number, third_number, dartsThrown = first_number + 2, second_number + 2, third_number + 2,dartsThrown + 1
Fetching token
?