%I #51 Jul 17 2024 04:55:24
%S 2,1,6,5,26,25,22,21,106,105,102,101,90,89,86,85,426,425,422,421,410,
%T 409,406,405,362,361,358,357,346,345,342,341,1706,1705,1702,1701,1690,
%U 1689,1686,1685,1642,1641,1638,1637,1626,1625,1622,1621,1450,1449,1446
%N In the binary expansion of n, expand bits 1 -> 01 and 0 -> 10.
%C This is essentialy the Manchester encoding (defined by convention in IEEE802.3 opposed to the original version where the mappings are inverted published by G. E. Thomas in 1949 see ref) which transforms each bit by representing 1 as 01 and 0 as 10, ensuring a transition occurs in the middle of each bit period for synchronization.
%D Andrew S. Tanenbaum, Computer Networks (4th ed.), Prentice Hall, 2002, Pages 274-275, ISBN 0-13-066102-3.
%H Paolo Xausa, <a href="/A374625/b374625.txt">Table of n, a(n) for n = 0..10000</a>
%H Ralf Stephan, <a href="https://arxiv.org/abs/math/0307027">Divide-and-conquer generating functions. I. Elementary sequences</a>, arXiv:math/0307027 [math.CO], 2003, equation 2.4 with a(n) = a_n for case alpha=4, c=2, d=1 and n >= 1.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Manchester_code">Manchester code</a>.
%F a(n) = a(n+1) + 1 for n even.
%F a(n) = A030101(A179888(A030101(n))) for n odd.
%F a(2*n) = 4*a(n) + 2 for n>=1.
%F a(2*n+1) = 4*a(n) + 1 for n>=1.
%e a(5) = 25 because:
%e 5 is 101 and:
%e 1 | 0 | 1
%e 01 | 10 | 01
%e And: 11001 is 25.
%p a:= n-> 2-(n mod 2)+`if`(n<2, 0, 4*a(iquo(n, 2))):
%p seq(a(n), n=0..50); # _Alois P. Heinz_, Jul 15 2024
%t A374625[n_] := FromDigits[2 - IntegerDigits[n, 2], 4];
%t Array[A374625, 100, 0] (* _Paolo Xausa_, Jul 16 2024 *)
%o (Python)
%o def a(n):
%o s=''
%o for b in bin(n)[2:]:
%o s += '01'*(b=='1') + '10'*(b=='0')
%o return int(s,2)
%o print([a(n) for n in range(0,51)])
%o (Python)
%o def a(n):
%o d = {'0': '10', '1': '01'}
%o return int(''.join(map(d.get, bin(n)[2:])), 2)
%o print([a(n) for n in range(0,51)]) # _Jason Yuen_, Jul 15 2024
%o (Python)
%o a = lambda n: int(''.join("101"[b=='1':(b=='1')+2] for b in bin(n)[2:]), 2)
%o # _Peter Luschny_, Jul 15 2024
%o (Python)
%o def A374625(n): return ((1<<(n.bit_length()<<1)+1)-2)//3-int(bin(n)[2:],4) if n else 2 # _Chai Wah Wu_, Jul 16 2024
%Y Cf. A030101, A115637, A179888.
%K nonn,base,easy
%O 0,1
%A _DarĂo Clavijo_, Jul 14 2024