repl.it
@imnotyouraura/

pi approx

Python

gregory-leibniz series

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
attempts = int(input("how many attempts for pi?"))
currentAttempt = int(0)
divisor = 1
currentApproximation = 0
currentApproximation = currentApproximation + (4 / divisor)
for currentAttempt in range(0, attempts):
  divisor = divisor + 2
  currentApproximation = currentApproximation - (4 / divisor)
  print(currentApproximation)
  divisor = divisor + 2
  currentApproximation = currentApproximation + (4 / divisor)
  print(currentApproximation)
Fetching token
?