OFFSET
0,1
COMMENTS
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.
REFERENCES
Andrew S. Tanenbaum, Computer Networks (4th ed.), Prentice Hall, 2002, Pages 274-275, ISBN 0-13-066102-3.
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..10000
Ralf Stephan, Divide-and-conquer generating functions. I. Elementary sequences, 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.
Wikipedia, Manchester code.
FORMULA
EXAMPLE
a(5) = 25 because:
5 is 101 and:
1 | 0 | 1
01 | 10 | 01
And: 11001 is 25.
MAPLE
a:= n-> 2-(n mod 2)+`if`(n<2, 0, 4*a(iquo(n, 2))):
seq(a(n), n=0..50); # Alois P. Heinz, Jul 15 2024
MATHEMATICA
A374625[n_] := FromDigits[2 - IntegerDigits[n, 2], 4];
Array[A374625, 100, 0] (* Paolo Xausa, Jul 16 2024 *)
PROG
(Python)
def a(n):
s=''
for b in bin(n)[2:]:
s += '01'*(b=='1') + '10'*(b=='0')
return int(s, 2)
print([a(n) for n in range(0, 51)])
(Python)
def a(n):
d = {'0': '10', '1': '01'}
return int(''.join(map(d.get, bin(n)[2:])), 2)
print([a(n) for n in range(0, 51)]) # Jason Yuen, Jul 15 2024
(Python)
a = lambda n: int(''.join("101"[b=='1':(b=='1')+2] for b in bin(n)[2:]), 2)
# Peter Luschny, Jul 15 2024
(Python)
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
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Darío Clavijo, Jul 14 2024
STATUS
approved