OFFSET
1,1
LINKS
T. D. Noe, Table of n, a(n) for n = 1..1023
Ralf Stephan, Some divide-and-conquer sequences ...
Ralf Stephan, Table of generating functions
FORMULA
a(2n) = 2a(n), a(2n+1) = 2a(n) + 1 + 3*[n==0].
a(2^m+k) = 2^(m+2) + k, m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Aug 07 2016
EXAMPLE
18 in binary is 10010, so 18 is in sequence.
MATHEMATICA
Select[Range[4, 153], Take[IntegerDigits[#, 2], 3] == {1, 0, 0} &] (* Michael De Vlieger, Aug 07 2016 *)
PROG
(PARI) a(n)=n+3*2^floor(log(n)/log(2))
(Haskell)
import Data.List (transpose)
a004756 n = a004756_list !! (n-1)
a004756_list = 4 : concat (transpose [zs, map (+ 1) zs])
where zs = map (* 2) a004756_list
-- Reinhard Zumkeller, Dec 04 2015
(Python)
def A004756(n): return n+(3<<n.bit_length()-1) # Chai Wah Wu, Jul 13 2022
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
EXTENSIONS
Edited by Ralf Stephan, Oct 12 2003
STATUS
approved