cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A066058 #23 May 23 2025 15:30:33
%S A066058 0,2,11,44,19,20,275,326,259,202,103,74,1027,1070,1049,1072,1547,1310,
%T A066058 1117,794,569,398,3083,2154,1177,1064,4697,4264,4443,2678,2169,1422,
%U A066058 779,3226,1551,1114,1815,1062,4197,3106,8697,7238,16633,12302,6683
%N A066058 In base 2: smallest integer which requires n 'Reverse and Add' steps to reach a palindrome.
%C A066058 The analog of A023109 in base 2.
%H A066058 Chai Wah Wu, <a href="/A066058/b066058.txt">Table of n, a(n) for n = 0..100</a>
%H A066058 <a href="/index/Res#RAA">Index entries for sequences related to Reverse and Add!</a>
%e A066058 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 A066058 Table[ SelectFirst[Range[0, 20000], (np = #; i = 0;
%t A066058     While[ np != IntegerReverse[np, 2] && i <= n,
%t A066058      np = np + IntegerReverse[np, 2]; i++];
%t A066058 i == n ) &] , {n, 0, 44}] (* _Robert Price_, Oct 16 2019 *)
%o A066058 (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 A066058 (Python)
%o A066058 def A066058(n):
%o A066058     if n > 0:
%o A066058         k = 0
%o A066058         while True:
%o A066058             m = k
%o A066058             for i in range(n):
%o A066058                 s1 = format(m,'b')
%o A066058                 s2 = s1[::-1]
%o A066058                 if s1 == s2:
%o A066058                     break
%o A066058                 m += int(s2,2)
%o A066058             else:
%o A066058                 s1 = format(m,'b')
%o A066058                 if s1 == s1[::-1]:
%o A066058                     return k
%o A066058             k += 1
%o A066058     else:
%o A066058         return 0 # _Chai Wah Wu_, Jan 06 2015
%Y A066058 Cf. A066057, A023109, A062128, A062130, A033865, A006995, A057148.
%K A066058 base,nonn
%O A066058 0,2
%A A066058 _Klaus Brockhaus_, Dec 04 2001