login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A066058 In base 2: smallest integer which requires n 'Reverse and Add' steps to reach a palindrome. 6
0, 2, 11, 44, 19, 20, 275, 326, 259, 202, 103, 74, 1027, 1070, 1049, 1072, 1547, 1310, 1117, 794, 569, 398, 3083, 2154, 1177, 1064, 4697, 4264, 4443, 2678, 2169, 1422, 779, 3226, 1551, 1114, 1815, 1062, 4197, 3106, 8697, 7238, 16633, 12302, 6683 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,2

COMMENTS

The analog of A023109 in base 2.

LINKS

Chai Wah Wu, Table of n, a(n) for n = 0..100

Index entries for sequences related to Reverse and Add!

EXAMPLE

11 is the smallest integer which requires two steps to reach a base 2 palindrome (cf. A066057), so a(2) = 11; written in base 10: 11 -> 11 + 13 = 24 -> 24 + 3 = 27; written in base 2: 1011 -> 1011 + 1101 = 11000 -> 11000 + 11 = 11011.

MATHEMATICA

Table[ SelectFirst[Range[0, 20000], (np = #; i = 0;

    While[ np != IntegerReverse[np, 2] && i <= n,

     np = np + IntegerReverse[np, 2]; i++];

i == n ) &] , {n, 0, 44}] (* Robert Price, Oct 16 2019 *)

PROG

(ARIBAS): For function b2reverse see A066057; function a066058(mx: integer); var k, m, n, rev, steps: integer; begin for k := 0 to mx do n := 0; steps := 0; m := n; rev := b2reverse(m); while not(steps = k and m = rev) do inc(n); m := n; rev := b2reverse(m); steps := 0; while steps < k and m <> rev do m := m + rev; rev := b2reverse(m); inc(steps); end; end; write(n, ", "); end; end; a066058(45).

(Python)

def A066058(n):

....if n > 0:

........k = 0

........while True:

............m = k

............for i in range(n):

................s1 = format(m, 'b')

................s2 = s1[::-1]

................if s1 == s2:

....................break

................m += int(s2, 2)

............else:

................s1 = format(m, 'b')

................if s1 == s1[::-1]:

....................return k

............k += 1

....else:

........return 0 # Chai Wah Wu, Jan 06 2015

CROSSREFS

Cf. A066057, A023109, A062128, A062130, A033865, A006995, A057148.

Sequence in context: A050620 A027253 A241712 * A153440 A289645 A181369

Adjacent sequences:  A066055 A066056 A066057 * A066059 A066060 A066061

KEYWORD

base,nonn

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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 28 11:40 EDT 2020. Contains 334681 sequences. (Running on oeis4.)