Advertisement
Guest User

Untitled

a guest
May 25th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. def isqrt(n):
  2. """Uses Newton's method to calculate floor(sqrt(x)) using
  3. speedy nice (and free of float weirdness!) integer math."""
  4. x = n
  5. y = (x + 1) // 2
  6. while y < x:
  7. x = y
  8. y = (x + n // x) // 2
  9. return y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement