Hi! I’d like to report a test coverage gap in the Python track exercise (Perfect Numbers).
In short: I was able to submit a solution that does not handle all cases correctly, yet it still passed the test suite. The root cause is that the tests appear to miss some key perfect-square cases.
My approach was to iterate divisors only up to √n and use divisor pairs: if i divides n, then n//i also divides n. For any divisor pair (i, n//i), at least one of them is ≤ √n, so scanning up to √n is sufficient to discover all divisor pairs.
However, I wrote a loop like this:
limit = math.sqrt(number)
for i in range(1, math.ceil(limit)):
...
In Python, the upper bound of range is exclusive. When number is a perfect square, sqrt(number) is an integer k, but k is not included in the loop, so the factor k is missed (and for perfect squares it should be counted exactly once). This can change the classification result.
Counterexample: 196 = 14^2
Proper divisors of 196 are 1, 2, 4, 7, 14, 28, 49, 98, which sum to 203. Since 203 > 196, 196 should be classified as abundant.
If the square-root factor 14 is omitted, the sum becomes 203 − 14 = 189, which would incorrectly classify 196 as deficient.
Suggestion: add at least one perfect-square test case that exposes this issue (e.g., 196), or add a dedicated test for perfect squares, to prevent incorrect implementations from passing.