For which digits d, is it possible to add d to every digit of a square and get another square?
For example, adding 3 to each digit of 16 gives 49.However, adding zero to each digit in this manner is NOT permissible.
For which digits d are there infinitely many such squares?
*** Digit sums greater than 9 are not allowed. For example, you could not add 8 to the digits of 81 to get 169.
I tested numbers from 1 up to 10^5 to be squared.
There are successful solutions for d in {1,3,5,8}
Here I list
d: [first square, incremented square]
1: [[25, 36], [2025, 3136], [13225, 24336], [4862025, 5973136]],
2: [],
3: [[1, 4], [16, 49], [1156, 4489], [111556, 444889], [11115556, 44448889], [1111155556, 4444488889]],
4: [],
5: [[4, 9], [121, 676]],
6: [],
7: [],
8: [[1, 9]]
If 0 is included as the initial square, then d can take on two more values, although I don't think is what was intended.
Now d can be any of {1,3,4,5,8,9}
d: [first square, incremented square]
1: [0, 1]
4: [0, 4]
9: [0, 9]
It appears that d=3 can have infinite solutions.
The square of a sting of k 3s followed by a 4 is transformed by d=3 into
The square of a sting of k 6s followed by a 7.
--------------
digitDict = {key: [] for key in range(1,9)}
big = 100000
squares = [n*n for n in range(1, big)]
for s in squares:
strs = str(s)
m = int(max(strs))
for d in range(1,10-m):
t = int(''.join([ str(int(char) + d) for char in strs]))
if t in squares:
digitDict[d].append([s,t])
print(digitDict)
|
Posted by Larry
on 2024-04-15 09:47:09 |