login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A066057 'Reverse and Add' carried out in base 2 (cf. A062128); number of steps needed to reach a palindrome, or -1 if no palindrome is ever reached. 8
0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 2, 1, 0, 1, 0, 1, 4, 5, 0, -1, 2, 1, 4, -1, 0, -1, 2, 1, 0, 1, 0, 1, -1, 1, -1, 1, 2, 1, -1, 1, 2, 3, 0, -1, -1, 1, -1, 3, 0, 1, 2, 3, 2, 1, 2, 3, 2, -1, -1, 1, 0, 1, 0, 1, -1, 1, 2, 1, 4, 3, 0, 11, -1, 5, -1, -1, 2, 1, 2, 1, 4, -1, 0, -1, 2, 5, -1, -1, 2, 3, 0, -1, -1, 1, -1, 3, 0, 1, 4, 1, 10, 11, -1, -1, 0, -1, 2, -1, 4 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,12
COMMENTS
The analog of A033665 in base 2.
LINKS
EXAMPLE
10011 (19 in base 10) -> 10011 + 11001 = 101100 -> 101100 + 1101 = 111001 -> 111001 + 100111 = 1100000 -> 1100000 + 11 = 1100011 (palindrome) requires 4 steps, so a(19) = 4.
MATHEMATICA
limit = 10^4; (* Assumes that there is no palindrome if none is found before "limit" iterations *)
Table[np = n; i = 0;
While[np != IntegerReverse[np, 2] && i < limit,
np = np + IntegerReverse[np, 2]; i++];
If[i >= limit, -1, i], {n, 0, 111}] (* Robert Price, Oct 14 2019 *)
PROG
(ARIBAS): function b2reverse(a: integer): integer; var n, i, rev: integer; begin n := bit_length(a); for i := 0 to n-1 do if bit_test(a, i) = 1 then rev := bit_set(rev, n-1-i); end; end; return rev; end; function a066057(mx, stop: integer); var c, k, m, rev: integer; begin for k := 0 to mx do c := 0; m := k; rev := b2reverse(m); while m <> rev and c < stop do inc(c); m := m + rev; rev := b2reverse(m); end; if c < stop then write(c); else write(-1); end; write(" "); end; end; a066057(120, 300).
CROSSREFS
Sequence in context: A318702 A360536 A226519 * A060588 A221167 A286134
KEYWORD
base,sign
AUTHOR
Klaus Brockhaus, Dec 04 2001
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 18:58 EDT 2024. Contains 371781 sequences. (Running on oeis4.)