Find the smallest perfect square that begins with a 1 and remains a perfect square when this 1 is replaced with a 7.
The minimum such N is 1225. Its own square root is 35, while sqrt(7225) is 85.
guide=1;
found=false;
while ~found
guide=guide+1;
ones=ceil(sqrt(10^guide)):floor(sqrt(2*10^guide));
sevens=ceil(sqrt(7*10^guide)):floor(sqrt(8*10^guide));
ones=mod(ones.^2,10^guide);
sevens=mod(sevens.^2,10^guide);
int=intersect(ones,sevens);
if length(int)>0
disp(int)
for i=1:length(int)
disp([sqrt(10^guide+int(i)) sqrt(7*10^guide+int(i) )])
end
disp(' ')
if guide>5
break
end
end
end
finding
225
35 85
5625
125 275
22500 48225
350 850
385 865
155625 562500
1075 2675
1250 2750
The first line of each group shows the portion of the number without the leading digit (the 1 or the 7). The larger cases have two listed. The remaining line(s) each have the square root of the 1 version and the square root of the 7 version; in the case of two separate "remaining digits" on the same line, separate lines are used for each pair of square roots.
|
Posted by Charlie
on 2025-03-02 09:39:07 |