fork download
  1. # calculate moar pi!
  2. import math
  3.  
  4. pi=0
  5. k=1
  6. for k in range(1,1000001):
  7. pi += math.pow(-1,k+1) * 4/(2*k-1)
  8. logk = math.log(k)/math.log(10)
  9. if(logk - math.floor(logk) == 0):
  10. print("Iteration " + str(k))
  11. print(pi)
Success #stdin #stdout 3.26s 10104KB
stdin
Standard input is empty
stdout
Iteration 1
4.0
Iteration 10
3.0418396189294032
Iteration 100
3.1315929035585537
Iteration 10000
3.1414926535900345
Iteration 100000
3.1415826535897198