OFFSET
1,3
COMMENTS
This sequence gives the first occurrence of n in A016026.
"Of course, every positive integer has a palindromic representation in SOME base. If we let f(n) denote the smallest base relative to which n is palindromic, then clearly f(n) is no greater than n-1, because every number n has the palindromic form '11' in the base (n-1)." [See Math Pages link; f(n)=A016026(n).]
LINKS
Robert G. Wilson v, Table of n, a(n) for n = 1..1000
Math Pages, On General Palindromic Numbers
EXAMPLE
a(6) = 14 because 14_10 equals 22_6. And 14 is the least integer whose representation in base 6 yields a palindrome as its first palindrome. 7, though palindromic in base 6, is also palindromic in a base less than 6 (7_10 = 111_2 = 11_6) so 7 cannot be a(6).
MAPLE
N:= 100: # to get a(1) to a(N)
ispali:= proc(k, b) local L; L:= convert(k, base, b); L = ListTools:-Reverse(L); end proc:
Needed:= N-1:
for k from 1 while Needed > 0 do
for b from 2 to N while not ispali(k, b) do od:
if b <= N and not assigned(A[b]) then A[b]:= k; Needed:= Needed - 1 fi
od:
0, seq(A[n], n=1..N); # Robert Israel, Nov 04 2014
MATHEMATICA
f[n_] := Block[{b = 2}, While[ Reverse[idn = IntegerDigits[n, b]] != idn, b++]; b]; a = Array[f, 3000]; Table[ Position[a, n, 1, 1], {n, 2, 60}] // Flatten
PROG
(PARI) a(n)=m=1; while(m, c=0; for(k=2, n-1, D=digits(m, k); if(D==Vecrev(D), c++; break)); if(!c&&(d=digits(m, n))==Vecrev(d), return(m)); m++)
print1(0, ", "); for(n=2, 100, print1(a(n), ", ")) \\ Derek Orr, Nov 02 2014
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Robert G. Wilson v, Nov 02 2014
STATUS
approved