added assertion that n >= 0

This commit is contained in:
jonny rhea 2019-01-10 18:09:58 -06:00
parent 1c42a9daca
commit d2eca73482
1 changed files with 1 additions and 0 deletions

View File

@ -1097,6 +1097,7 @@ def integer_squareroot(n: int) -> int:
"""
The largest integer ``x`` such that ``x**2`` is less than ``n``.
"""
assert n >= 0
x = n
y = (x + 1) // 2
while y < x: