OFFSET
0,4
COMMENTS
This is essentialy the mapping of the half adder where the inputs A,B maps to outputs: C_out and S as in binary: 00->00, 01->01, 10->01, 11->10, where C_out is the carry out bit and S is the sum bit.
The fixed points for this sequence are in the Moser-de Bruijn sequence (A000695).
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..10000
Wikipedia, Adder (electronics)
FORMULA
EXAMPLE
Half adder truth table:
A | B | C_out | S
---+---+-------+------
0 | 0 | 0 | 0
0 | 1 | 0 | 1
1 | 0 | 0 | 1
1 | 1 | 1 | 0
For n = 25 a(25) = 21 because:
25 = 121_4 and 121_4 maps to 111_4 which is 21.
MATHEMATICA
A380110[n_] := FromDigits[ReplaceAll[IntegerDigits[n, 4], {2 -> 1, 3 -> 2}], 4];
Array[A380110, 100, 0] (* Paolo Xausa, Feb 27 2025 *)
PROG
(Python)
def a(n):
r, p = 0, 1
while n:
ps = (n & 1) + ((n >> 1) & 1)
r += ps * p
n >>= 2
p <<= 2
return r
print([a(n) for n in range(70)])
CROSSREFS
KEYWORD
nonn,base,easy,new
AUTHOR
Darío Clavijo, Feb 14 2025
STATUS
approved