login
A077402
Reverse and Add! carried out in base 3; number of steps needed to reach a palindrome, or -1 if no palindrome is ever reached.
2
0, 0, 0, 1, 0, 2, 1, 2, 0, 1, 0, 2, 1, 0, 2, 3, 0, 4, 1, 2, 0, 1, 2, 0, 3, 4, 0, 1, 0, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 0, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 3, 0, 18, 1, 2, 0, 1, 2, 4, 1, 2, 2, 1, 2, 4, 1, 2, 0, 3, 2, 4, 1, 2, 2, 3, 2, 4, 17, 18, 0, 1, 0, 2, 1, 1, 2, 1, 1, 3, 1, 0, 2, 1, 1, 16, 1, 1, 2, 2, 0, 2, 4, -1, 16, 3, 15, 2, 1, 1, 2, 1, 0, 3, 3, 3, 2, 1, 1, 16, 1
OFFSET
0,6
COMMENTS
Base-3 analog of A066057 (base 2), A075685 (base 4) and A033665 (base 10). a(103) = -1 is a conjecture (cf. A066450, A077408). For values of n such that presumably a(n) = -1 see A077404.
EXAMPLE
17 (decimal) = 122 -> 122 + 221 = 1120 -> 1120 + 211 = 2101 -> 2101 + 1012 = 10120 -> 10120 + 2101 = 12221 (palindrome) = 160 (decimal) requires 4 steps, so a(17) = 4.
PROG
(ARIBAS) m := 120; stop := 1000; for n := 0 to m do v := -1; c := 0; k := n; while c < stop 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 := stop; else inc(c); k := k + rev; end; end; write(v, ", "); end;
KEYWORD
base,sign
AUTHOR
Klaus Brockhaus, Nov 05 2002
STATUS
approved