login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Binary expansion of nonnegative integers expanded to "Zeckendorffian format" with rewrite rules 0->0, 1->01.
14

%I #57 Apr 24 2024 22:16:38

%S 0,1,2,5,4,9,10,21,8,17,18,37,20,41,42,85,16,33,34,69,36,73,74,149,40,

%T 81,82,165,84,169,170,341,32,65,66,133,68,137,138,277,72,145,146,293,

%U 148,297,298,597,80,161,162,325,164,329,330,661,168,337,338,677,340

%N Binary expansion of nonnegative integers expanded to "Zeckendorffian format" with rewrite rules 0->0, 1->01.

%C No two adjacent 1-bits. Permutation of A003714.

%C Replace 1 with 01 in binary. - _Ralf Stephan_, Oct 07 2003

%H Reinhard Zumkeller, <a href="/A048678/b048678.txt">Table of n, a(n) for n = 0..10000</a>

%H N. J. A. Sloane, <a href="/transforms.txt">Transforms</a>

%F a(n) = rewrite_0to0_1to01(n) [ Each 0->1, 1->10 in binary expansion of n ].

%F a(0)=0; a(n) = (3-(-1)^n)*a(floor(n/2))+(1-(-1)^n)/2. - _Benoit Cloitre_, Aug 31 2003

%F a(0)=0, a(2n) = 2a(n), a(2n+1) = 4a(n) + 1. - _Ralf Stephan_, Oct 07 2003

%e 11=1011 in binary, thus is rewritten as 100101 = 37 in decimal.

%p rewrite_0to0_1to01 := proc(n) option remember; if(n < 2) then RETURN(n); else RETURN(((2^(1+(n mod 2))) * rewrite_0to0_1to01(floor(n/2))) + (n mod 2)); fi; end;

%t f[n_] := FromDigits[ Flatten[IntegerDigits[n, 2] /. {1 -> {0, 1}}], 2]; Table[f@n, {n, 0, 60}] (* _Robert G. Wilson v_, Dec 11 2009 *)

%o (PARI) a(n)=if(n<1,0,(3-(-1)^n)*a(floor(n/2))+(1-(-1)^n)/2)

%o (PARI) a(n) = if(n == 0, 0, my(A = -2); sum(i = 0, logint(n, 2), A++; if(bittest(n, i), 1 << (A++)))) \\ _Mikhail Kurkov_, Mar 14 2024

%o (Haskell)

%o a048678 0 = 0

%o a048678 x = 2 * (b + 1) * a048678 x' + b

%o where (x', b) = divMod x 2

%o -- _Reinhard Zumkeller_, Mar 31 2015

%o (Python)

%o def a(n):

%o return 0 if n==0 else (3 - (-1)**n)*a(n//2) + (1 - (-1)**n)//2

%o print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 30 2017

%o (Python)

%o def A048678(n): return int(bin(n)[2:].replace('1','01'),2) # _Chai Wah Wu_, Mar 18 2024

%Y Cf. A003714, A005203, A048679, A048680.

%Y MASKTRANS transform of A053644.

%Y Cf. A084471, A088697, A088698.

%Y Cf. A124108.

%K nonn,easy

%O 0,3

%A _Antti Karttunen_