login
A379578
In the base-4 expansion of n map 0->1, 1->3, 2->0, 3->2.
1
1, 3, 0, 2, 13, 15, 12, 14, 1, 3, 0, 2, 9, 11, 8, 10, 53, 55, 52, 54, 61, 63, 60, 62, 49, 51, 48, 50, 57, 59, 56, 58, 5, 7, 4, 6, 13, 15, 12, 14, 1, 3, 0, 2, 9, 11, 8, 10, 37, 39, 36, 38, 45, 47, 44, 46, 33, 35, 32, 34, 41, 43, 40, 42, 213, 215, 212, 214, 221
OFFSET
0,2
COMMENTS
Obviously a(n) != n. Also a(a(n)) is the binary complement of n.
This mapping correspond in binary to 00->01, 01->11, 10->00, 11->10, after prefixing an initial 0 if the bit length is odd.
LINKS
FORMULA
a(n) = a(n-1) + 2 for n odd.
a(A020988(n)) = 0.
a(n) = (-7(-2)^k + 15(2^k)-8)/12 for n=2^k-1.
EXAMPLE
a(141) = 27 since 141 = 10001101_2 -> 00011011_2 = 27.
MATHEMATICA
A379578[n_] := FromDigits[StringReplace[IntegerString[n, 4], {"0"->"1", "1"->"3", "2"->"0", "3"->"2"}], 4];
Array[A379578, 100, 0] (* Paolo Xausa, Jan 06 2025 *)
PROG
(Python)
def tobase4(n):
if n == 0: return [0]
d = []
while n > 0:
d.append(n & 3)
n >>= 2
return d[::-1]
def a(n):
if n & 1: return a(n-1) + 2
B4 = ["1", "3", "0", "2"]
return int("".join(B4[b] for b in tobase4(n)), 4)
print([a(n) for n in range(0, 69)])
CROSSREFS
KEYWORD
nonn,base,easy,look
AUTHOR
Darío Clavijo, Dec 26 2024
STATUS
approved