Three students write on the blackboard next to each other three two-digit squares. In the end, they observe that the 6-digit number thus obtained is also a square. Find this number!
clc
sqs=[];
for i=4:9
sqs=[sqs i*i];
end
sets=[]; ct=0;
for a=1:6
for b=a:6
for c=b:6
sets=[sets;[sqs(a) sqs(b) sqs(c)]];
end
end
end
for i=1:size(sets,1)
p=unique(perms(sets(i,:)),'rows');
for j=1:size(p,1)
sq3=p(j,:);
n=10000*sq3(1)+100*sq3(2)+sq3(3);
sr=round(sqrt(n));
if sr*sr==n
disp([n sr])
end
ct=ct+1;
end
end
disp(ct)
finds 2 solutions:
166464 = 408^2
646416 = 804^2
from the 6^3 = 216 possible ways of forming them.
|
Posted by Charlie
on 2021-02-13 14:05:42 |