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.
%I A340836 #48 Mar 14 2021 14:26:31 %S A340836 0,1,3,3,5,5,7,7,9,9,11,11,11,11,15,15,17,17,19,19,19,19,19,19,19,19, %T A340836 23,23,23,23,31,31,33,33,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, %U A340836 35,39,39,39,39,39,39,39,39,47,47,47,47,63,63,65,65,67,67 %N A340836 a(n) is the least k such that the binary reversal of k is greater than or equal to n. %C A340836 A030101 gives the binary reversal of a number. %C A340836 All positive terms belong to A209492. %C A340836 This sequence is nondecreasing. %H A340836 Rémy Sigrist, <a href="/A340836/b340836.txt">Table of n, a(n) for n = 0..8192</a> %F A340836 a(n) <= n + 1. %e A340836 For n = 8: %e A340836 - A030101(k) < 8 for any k <= 8, %e A340836 - A030101(9) = 9 >= 8, %e A340836 - so a(8) = 9. %o A340836 (PARI) { base = 2; k = 0; r = 0; for (n=0, 67, while (r<n, r = fromdigits(Vecrev(digits(k++, base)), base);); print1 (k ", ")) } %o A340836 (Python) %o A340836 def A340836(n): %o A340836 if n == 0: %o A340836 return 0 %o A340836 s = bin(n)[2:] %o A340836 i = s.find('0') %o A340836 if i == -1: %o A340836 return n %o A340836 s1, s2 = s[:i+1], s[i+1:] %o A340836 if s2 == '': %o A340836 return n+1 %o A340836 if int(s2) <= 1: %o A340836 return int('1'+s2[-2::-1]+s1[::-1],2) %o A340836 else: %o A340836 return int('1'+'0'*(len(s2)-1)+bin(int(s1,2)+1)[:1:-1],2) # _Chai Wah Wu_, Mar 14 2021 %Y A340836 Cf. A030101, A209492, A340835 (decimal analog). %K A340836 nonn,base %O A340836 0,3 %A A340836 _Rémy Sigrist_, Mar 13 2021