A 3-digit decimal (base ten) Palindrome P is such that when expressed in base N, with N being a positive integer between 2 and 36 inclusively (base 10 excluded), at least one of them is also a palindrome.
M denotes the total count of such non base ten palindrome for a given value of decimal palindrome P.
Which value or values of P maximises the value of M?
clearvars, clc
ct=[];
for beg=10:99
pct=0;
pal10=beg*10+floor(beg/10);
for b=[2:9 11:36]
n=dec2base(pal10,b);
if ispal(n)
fprintf('%3d %10s %3d
',pal10,n,b);
pct=pct+1;
end
end
ct=[ct;pal10, pct];
end
ct=sortrows(ct,2);
disp(ct)
M=sum(ct(:,2))
function ip=ispal(s)
ip=true;
for i=1:floor(length(s)/2)
if s(i)~=s(end+1-i)
ip=false;
break
end
end
end
finds
M =
140
This is actually the sum of all the M as defined in the puzzle. The individual M values are found below.
The P that maximizes the number of non-base-10 palindromes is 252, which finds 5 such palindromes:
representaton base
252 2002 5
252 EE 17
252 CC 20
252 99 27
252 77 35
The runners-up may be more interesting, with longer palindromes:
666 22122 4
666 3C3 13
666 1G1 19
666 II 36
676 10201 5
676 565 11
676 484 12
676 121 25
The P values with at least one non-base-10 palindrome are:
base-10 count
141 1
151 1
161 1
181 1
212 1
272 1
363 1
393 1
454 1
545 1
565 1
686 1
696 1
727 1
767 1
818 1
848 1
909 1
929 1
939 1
949 1
111 2
171 2
191 2
222 2
232 2
282 2
292 2
313 2
323 2
333 2
353 2
414 2
434 2
444 2
484 2
494 2
505 2
525 2
575 2
585 2
616 2
646 2
656 2
717 2
737 2
777 2
797 2
828 2
838 2
868 2
888 2
898 2
919 2
979 2
999 2
121 3
242 3
343 3
373 3
464 3
555 3
595 3
626 3
757 3
787 3
858 3
989 3
666 4
676 4
252 5
Edited on June 7, 2022, 10:25 am
|
Posted by Charlie
on 2022-06-07 10:23:45 |