Repository navigation
Commit 660943b
committed
fix: check perfect squares with math.isqrt instead of floats
math.sqrt(num) * math.sqrt(num) == num rounds: it holds for 11, 14, 17 and about half of all other non-squares below 200000, and fails for large squares such as (2**53 + 1) ** 2. math.isqrt is exact, and the result now agrees with perfect_square_binary_search() for every n below 300000.1 parent 6e03a48 commit 660943b
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | | - | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
0 commit comments