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 f9680cf commit 5523aecCopy full SHA for 5523aec
maths/rare_number.py
@@ -52,7 +52,7 @@ def rare_numbers(start: int, end: int) -> list[int]:
52
rev_n = _reverse_number(n)
53
if n == rev_n:
54
continue # skip palindromes
55
- if _is_perfect_square(n + rev_n) and _is_perfect_square(abs(n - rev_n)):
+ if n - rev_n > 0 and _is_perfect_square(n + rev_n) and _is_perfect_square(n - rev_n):
56
rares.append(n)
57
return rares
58
@@ -98,7 +98,7 @@ def _is_perfect_square(n: int) -> bool:
98
"""
99
if n < 0:
100
return False
101
- root = int(math.isqrt(n))
+ root = math.isqrt(n)
102
return root * root == n
103
104
0 commit comments