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!)
A004757 Binary expansion starts 101. 10
5, 10, 11, 20, 21, 22, 23, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
FORMULA
a(2n) = 2a(n), a(2n+1) = 2a(n) + 1 + 4*[n==0].
a(n) = n + 4 * 2^floor(log_2(n)) = A004756(n) + A053644(n).
a(2^m+k) = 5*2^m + k, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Aug 08 2016
EXAMPLE
22 in binary is 10110, so 22 is in sequence.
MATHEMATICA
Table[n + 4*2^Floor@ Log2@ n, {n, 57}] (* or *)
w = {1, 0, 1}; Select[Range[5, 185], If[# < 2^(Length@ w - 1), True, Take[IntegerDigits[#, 2], Length@ w] == w] &] (* Michael De Vlieger, Aug 10 2016 *)
Select[Range[5, 200], Take[IntegerDigits[#, 2], 3]=={1, 0, 1}&] (* Harvey P. Dale, Aug 26 2016 *)
PROG
(PARI) a(n)=n+4*2^floor(log(n)/log(2))
(Haskell)
import Data.List (transpose)
a004757 n = a004757_list !! (n-1)
a004757_list = 5 : concat (transpose [zs, map (+ 1) zs])
where zs = map (* 2) a004757_list
-- Reinhard Zumkeller, Dec 04 2015
(Python)
def A004757(n): return n+(2<<n.bit_length()) # Chai Wah Wu, Jul 13 2022
CROSSREFS
Cf. A004754 (10), A004755 (11), A004756 (100), A004758 (110), A004759 (111).
Sequence in context: A136822 A189151 A120513 * A007527 A033894 A033649
KEYWORD
nonn,base,easy
AUTHOR
EXTENSIONS
Edited by Ralf Stephan, Oct 12 2003
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 May 9 05:13 EDT 2024. Contains 372344 sequences. (Running on oeis4.)