Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45e0411 commit 2dfeaa9Copy full SHA for 2dfeaa9
1 file changed
Modules/mathmodule.c
@@ -1527,10 +1527,10 @@ Here's Python code equivalent to the C implementation below:
1527
a = 1
1528
d = 0
1529
for s in reversed(range(c.bit_length())):
1530
+ # Loop invariant: (a-1)**2 < (n >> 2*(c - d)) < (a+1)**2
1531
e = d
1532
d = c >> s
1533
a = (a << d - e - 1) + (n >> 2*c - e - d + 1) // a
- assert (a-1)**2 < n >> 2*(c - d) < (a+1)**2
1534
1535
return a - (a*a > n)
1536
0 commit comments