A positive integer is called Sabroso if when it is added to the number obtained when its digits are interchanged from one side of its written form to the other, the result is a perfect square. For example, 143 is Sabroso, since 143+341=484=222. Find all two-digit Sabroso numbers.
Sabroso numbers:
1-digit: 2, 8
2-digit: 29, 38, 47, 56, 65, 74, 83, 92
3-digit: 110, 143, 164, 198, 242, 263, 297, 341, 362, 396, 440, 461, 495, 560, 594, 693, 792, 891, 990
4-digit: none
There are 169 5-digit Sabroso numbers.
The 1-digit Sabroso numbers evaluate to squares of 2 and 4
All 8 2-digit Sabroso numbers evaluate to 11^2
The 3-digit Sabroso numbers evaluate to squares of 11, 22, 25, and 33
The 5-digit Sabroso numbers evaluate to squares of 101, 121, 141, 202, 222, 264, 303, 307
-----------------
def issabroso(n):
""" Sabroso integer is when n + rev(n) is a square """
r = int(str(n)[::-1])
if issquare(n+r):
return True
else:
return False
sabrosos = []
for n in range(10,100):
if issabroso(n):
sabrosos.append(n)
revn = int(str(n)[::-1])
print(n, revn, int((n+revn)**.5))
|
Posted by Larry
on 2024-06-10 11:41:56 |