A036044 BCR(n): write in binary, complement, reverse.
1, 0, 2, 0, 6, 2, 4, 0, 14, 6, 10, 2, 12, 4, 8, 0, 30, 14, 22, 6, 26, 10, 18, 2, 28, 12, 20, 4, 24, 8, 16, 0, 62, 30, 46, 14, 54, 22, 38, 6, 58, 26, 42, 10, 50, 18, 34, 2, 60, 28, 44, 12, 52, 20, 36, 4, 56, 24, 40, 8, 48, 16, 32, 0, 126, 62, 94, 30, 110, 46, 78, 14, 118, 54, 86
Offset: 0
Examples
4 -> 100 -> 011 -> 110 -> 6.
Links
- Indranil Ghosh, Table of n, a(n) for n = 0..10000 (first 1024 terms from T. D. Noe)
Crossrefs
Programs
-
Haskell
import Data.List (unfoldr) a036044 0 = 1 a036044 n = foldl (\v d -> 2 * v + d) 0 (unfoldr bc n) where bc 0 = Nothing bc x = Just (1 - m, x') where (x',m) = divMod x 2 -- Reinhard Zumkeller, Sep 16 2011
-
Magma
A036044:=func
; // Jason Kimberley, Sep 19 2011 -
Maple
A036044 := proc(n) local bcr ; if n = 0 then return 1; end if; convert(n,base,2) ; bcr := [seq(1-i,i=%)] ; add(op(-k,bcr)*2^(k-1),k=1..nops(bcr)) ; end proc: seq(A036044(n),n=0..200) ; # R. J. Mathar, Nov 06 2017
-
Mathematica
dtn[ L_ ] := Fold[ 2#1+#2&, 0, L ]; f[ n_ ] := dtn[ Reverse[ 1-IntegerDigits[ n, 2 ] ] ]; Table[ f[ n ], {n, 0, 100} ] Table[FromDigits[Reverse[IntegerDigits[n,2]/.{1->0,0->1}],2],{n,0,80}] (* Harvey P. Dale, Mar 08 2015 *)
-
PARI
a(n)=fromdigits(Vecrev(apply(n->1-n,binary(n))),2) \\ Charles R Greathouse IV, Apr 22 2015
-
Python
def comp(s): z, o = ord('0'), ord('1'); return s.translate({z:o, o:z}) def BCR(n): return int(comp(bin(n)[2:])[::-1], 2) print([BCR(n) for n in range(75)]) # Michael S. Branicky, Jun 14 2021
-
Python
def A036044(n): return -int((s:=bin(n)[-1:1:-1]),2)-1+2**len(s) # Chai Wah Wu, Feb 04 2022
Formula
a(2n) = 2*A059894(n), a(2n+1) = a(2n) - 2^floor(log_2(n)+1). - Ralf Stephan, Aug 21 2003
Conjecture: a(n) = (-1)^A023416(n)*b(n) for n > 0 with a(0) = 1 where b(2^m) = (-1)^m*(2^(m+1) - 2) for m >= 0, b(2n+1) = b(n) for n > 0, b(2n) = b(n) + b(n - 2^f(n)) + b(2n - 2^f(n)) for n > 0 and where f(n) = A007814(n) (see A329369). - Mikhail Kurkov, Dec 13 2024
Comments