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.
for i=1:9999999
sq=i^2;
sqs=num2str(sq);
for j=1:9
a=repmat(j,1,length(sqs))+sqs;
if max(a-48)>9
break
end
sq2=str2double(char(a));
if sqrt(sq2)==round(sqrt(sq2))
fprintf('%15d %2d %15d
',[sq j sq2])
end
end
end
finds, for its range, only
first square incr second square
1 3 4
1 8 9
4 5 9
16 3 49
25 1 36
121 5 676
1156 3 4489
2025 1 3136
13225 1 24336
111556 3 444889
4862025 1 5973136
11115556 3 44448889
1111155556 3 4444488889
60415182025 1 71526293136
102442244356 3 435775577689
111111555556 3 444444888889
207612366025 1 318723477136
11111115555556 3 44444448888889
It looks like repeated digt 3 has a pattern that will always work, with squares of numbers like 333334^2 being transformed into 6666667^2,
Edited on April 15, 2024, 8:58 am
|
Posted by Charlie
on 2024-04-15 08:56:59 |