OFFSET
0,2
EXAMPLE
5 is the smallest number which requires two steps to reach a base 3 palindrome (cf. A066057), so a(2) = 5; 5 (decimal) = 12 -> 12 + 21 = 110 -> 110 + 011 = 121 (palindrome) = 16 (decimal).
PROG
(ARIBAS) var ar: array; end; m := 45; ar := alloc(array, m+1, -1); mc := m+1; n := 0; while mc > 0 do v := -1; c := 0; k := n; while c < m+1 do d := k; rev := 0; while d > 0 do rev := 3*rev+(d mod 3); d := d div 3; end; if k = rev then v := c; c := m+1; else inc(c); k := k+rev; end; end; if 0 <= v and v <= m then if ar[v] < 0 then ar[v] := n; dec(mc); write((v, n)); end; end; inc(n); end; writeln(); for j := 0 to m do write(ar[j], ", "); end;
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Klaus Brockhaus, Nov 05 2002
STATUS
approved