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!)
A340836 a(n) is the least k such that the binary reversal of k is greater than or equal to n. 2
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, 23, 23, 23, 23, 31, 31, 33, 33, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39, 39, 39, 39, 39, 39, 39, 39, 47, 47, 47, 47, 63, 63, 65, 65, 67, 67 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
A030101 gives the binary reversal of a number.
All positive terms belong to A209492.
This sequence is nondecreasing.
LINKS
FORMULA
a(n) <= n + 1.
EXAMPLE
For n = 8:
- A030101(k) < 8 for any k <= 8,
- A030101(9) = 9 >= 8,
- so a(8) = 9.
PROG
(PARI) { base = 2; k = 0; r = 0; for (n=0, 67, while (r<n, r = fromdigits(Vecrev(digits(k++, base)), base); ); print1 (k ", ")) }
(Python)
def A340836(n):
if n == 0:
return 0
s = bin(n)[2:]
i = s.find('0')
if i == -1:
return n
s1, s2 = s[:i+1], s[i+1:]
if s2 == '':
return n+1
if int(s2) <= 1:
return int('1'+s2[-2::-1]+s1[::-1], 2)
else:
return int('1'+'0'*(len(s2)-1)+bin(int(s1, 2)+1)[:1:-1], 2) # Chai Wah Wu, Mar 14 2021
CROSSREFS
Cf. A030101, A209492, A340835 (decimal analog).
Sequence in context: A177691 A206913 A117767 * A293701 A296063 A127630
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 13 2021
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 24 20:08 EDT 2024. Contains 371963 sequences. (Running on oeis4.)