fork download
  1. import sys
  2. import math
  3.  
  4. a = 1.0
  5. b = 1.0/math.sqrt(2)
  6. t = 1.0/4.0
  7. p = 1.0
  8.  
  9. while True:
  10. at = (a+b)/2
  11. bt = math.sqrt(a*b)
  12. tt = t - p*(a-at)**2
  13. pt = 2*p
  14. a = at;b = bt;t = tt;p = pt
  15. my_pi = (a+b)**2/(4*t)
  16.  
  17. print("pi to the last digit = " + str(my_pi))
Time limit exceeded #stdin #stdout 5s 9024KB
stdin
Standard input is empty
stdout
Standard output is empty