fork download
  1. s = 13
  2. x = 17
  3.  
  4. def f(x):
  5. return (x + s/x)/2
  6.  
  7. tol = 999
  8.  
  9. while True:
  10. tap = f(x)
  11. if abs(tap - x) < tol:
  12. break
  13. x = tap
  14.  
  15. print(x)
Success #stdin #stdout 0.01s 7200KB
stdin
Standard input is empty
stdout
17