A duodecimal perfect square N has
strictly ascending digits from left to right.
Determine the maximum value of N.
How about the maximum value of N when it has strictly descending duodecimal digits from left to right.
The tables below show all the perfect squares meeting the ascending or descending digit order in base 12.
Part 1:
perfect square square root
base-12 dec dec base-12
1 1 1 1
4 4 2 2
9 9 3 3
14 16 4 4
69 81 9 9
169 225 15 13
2369 3969 63 53
The answer is 2369 base-12 or 3969 decimal.
Part 2:
1 1 1 1
4 4 2 2
9 9 3 3
21 25 5 5
30 36 6 6
41 49 7 7
54 64 8 8
84 100 10 A
A1 121 11 B
630 900 30 26
861 1225 35 2B
961 1369 37 31
B81 1681 41 35
7630 12996 114 96
A854 18496 136 B4
B7621 241081 491 34B
The answer is B7621 in duodecimal or 241081 decimal.
from
for sr=1:2985984
sq=sr^2;
b12=dec2base(sq,12);
good=true;
for i=1:length(b12)-1
if b12(i)>=b12(i+1)
good=false;
break
end
end
if good
fprintf('%7s %7d %7d %7s\n',b12,sq,sr,dec2base(sr,12));
end
end
for sr=1:2985984
sq=sr^2;
b12=dec2base(sq,12);
good=true;
for i=1:length(b12)-1
if b12(i)<=b12(i+1)
good=false;
break
end
end
if good
fprintf('%7s %7d %7d %7s\n',b12,sq,sr,dec2base(sr,12));
end
end
But how about some other bases? In each set below the base is followed by the highest set for the type (ascending/descending) in the same formatted line as shown for base 12 above.
3
1 1 1 1
1 1 1 1
4
1 1 1 1
210 36 6 12
5
14 9 3 3
31 16 4 4
6
24 16 4 4
321 121 11 15
7
34 25 5 5
642 324 18 24
8
4 4 2 2
620 400 20 24
9
1357 1024 32 35
8310 6084 78 86
10
134689 134689 367 367
961 961 31 31
11
23489 33856 184 158
961 1156 34 31
12
2369 3969 63 53
B7621 241081 491 34B
13
12689AC 5760000 2400 1128
BA853 337561 581 359
After base 13, Matlab complained about the max numbers to be checked, and so I stopped. The code shows I attempted to go to base 36.
for b=3:36
disp(b);
largest='';
for i=1:b-1
largest=[largest dec2base(i,b)];
end
for sr=1:floor(sqrt(base2dec(largest,b)))
sq=sr^2;
b12=dec2base(sq,b);
good=true;
for i=1:length(b12)-1
if b12(i)>=b12(i+1)
good=false;
break
end
end
if good
maxim=sprintf('%7s %7d %7d %7s ',b12,sq,sr,dec2base(sr,b));
end
end
disp(maxim)
largest='';
for i=b-1:-1:0
largest=[largest dec2base(i,b)];
end
for sr=1:floor(sqrt(base2dec(largest,b)))
sq=sr^2;
b12=dec2base(sq,b);
good=true;
for i=1:length(b12)-1
if b12(i)<=b12(i+1)
good=false;
break
end
end
if good
maxim=sprintf('%7s %7d %7d %7s\n',b12,sq,sr,dec2base(sr,b));
end
end
disp(maxim)
end
|
Posted by Charlie
on 2022-08-06 09:55:01 |