1^2 = 1
3^2 = 9
are the only two squares with all odd digits.
Further squares all have at least two digits. The even numbers of course end in an even digit, whose square is also even.
Of the odd last digits the following list is all the possible last two digits for squares of odd numbers of two or more digits (the squares mod 100):
01 09 25 49 81
21 69 25 89 61
41 29 25 29 41
61 89 25 69 21
81 49 25 09 01
01 09 25 49 81
21 69 25 89 61
41 29 25 29 41
61 89 25 69 21
81 49 25 09 01
All contain an even digit as the next to last digit.
Producing the array was a challenge in the MATLAB language that I am learning, especially the distinction between char format, which is already considered an array of characters, and the string format, which is a single scalar consisting of more than one character, so its length (measured in how many entries in its vector) is only 1:
for n=101:2:199
if mod(n,10)== 1
i=0;
end
nsq=string(n*n);
l=length(char(nsq));
dig2=substr(nsq,(l-1):l);
i=i+1;
dig2=double(dig2);
row(i)=dig2;
if mod(n,10)==9
fprintf(' %02d %02d %02d %02d %02d\n',row)
end
end
where substr() is defined by
function outstr = substr(x,r)
c=char(x);
c2=c(r);
outstr=string(c2);
end
|
Posted by Charlie
on 2020-10-05 10:49:40 |