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!)
A066058 In base 2: smallest integer which requires n 'Reverse and Add' steps to reach a palindrome. 6

%I #17 Oct 16 2019 17:37:10

%S 0,2,11,44,19,20,275,326,259,202,103,74,1027,1070,1049,1072,1547,1310,

%T 1117,794,569,398,3083,2154,1177,1064,4697,4264,4443,2678,2169,1422,

%U 779,3226,1551,1114,1815,1062,4197,3106,8697,7238,16633,12302,6683

%N In base 2: smallest integer which requires n 'Reverse and Add' steps to reach a palindrome.

%C The analog of A023109 in base 2.

%H Chai Wah Wu, <a href="/A066058/b066058.txt">Table of n, a(n) for n = 0..100</a>

%H <a href="/index/Res#RAA">Index entries for sequences related to Reverse and Add!</a>

%e 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.

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

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

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

%t i == n ) &] , {n, 0, 44}] (* _Robert Price_, Oct 16 2019 *)

%o (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).

%o (Python)

%o def A066058(n):

%o ....if n > 0:

%o ........k = 0

%o ........while True:

%o ............m = k

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

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

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

%o ................if s1 == s2:

%o ....................break

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

%o ............else:

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

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

%o ....................return k

%o ............k += 1

%o ....else:

%o ........return 0 # _Chai Wah Wu_, Jan 06 2015

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

%K base,nonn

%O 0,2

%A _Klaus Brockhaus_, Dec 04 2001

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 11:52 EDT 2024. Contains 371779 sequences. (Running on oeis4.)