Determine three positive integers A, B and C such that the concatenations AB, AC and BC are all squares, and the sum A+B+C is also a square.
tots=1;
for n=2:5000
tots(end+1)=n^2;
end
for t=3:length(tots)
tot=tots(t);
for a=1:tot-2
as=num2str(a);
for b=1:tot-a-1
bs=num2str(b);
c=tot-a-b;
cs=num2str(c);
ab=str2double([as bs]);
sr=round(sqrt(ab));
if sr^2==ab
ac=str2double([as cs]);
sr=round(sqrt(ac));
if sr^2==ac
bc=str2double([bs cs]);
sr=round(sqrt(bc));
if sr^2==bc
disp([a b c])
end
end
end
end
end
end
finds
>> threeConcatenations
108 16 900
Operation terminated by user during int2str
showing A, B and C.
AB = 10816 = 104^2
AC = 108900 = 330^2
BC = 16900 = 130^2
|
Posted by Charlie
on 2024-03-15 10:48:05 |