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
Paolo Xausa, Table of n, a(n) for n = 0..16383
bitmath.blogspot.com, Square root of bitwise not
FORMULA
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
AUTHOR
Darío Clavijo, Dec 26 2024
STATUS
approved
