Two positive integers, a and b, are of 4 digits or less.
For what (a,b) pairs is it true that the sum of their squares is equal to their concatenation?
(In reply to
soln by Steven Lord)
It's not always 10,000 that you need to multiply by; it could be a smaller power of ten for shorter second numbers, to do a concatenation.
for a=1:9999
f=10;
for b=1:9999
if b==10 || b==100 || b==1000
f=f*10;
end
c=f*a+b;
if c==a^2+b^2
disp([a b a^2 b^2 c])
end
end
end
a b a^2 b^2 a^2+b^2
10 1 100 1 101
10 100 100 10000 10100
12 33 144 1089 1233
88 33 7744 1089 8833
588 2353 345744 5536609 5882353
990 100 980100 10000 990100
9412 2353 88585744 5536609 94122353
|
Posted by Charlie
on 2020-12-01 12:48:00 |