OFFSET
0,3
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
LINKS
EXAMPLE
a(7) = A338241(13) = 7.
PROG
(PARI) b(n) = { if (n==0, return (0), my (d=n%3, m=n\3); if (d==0, 3*b(m), d==1, 1-3*b(m), 3*b(m)-1)) }
a(n) = if (n==0, 0, b(2*n-1))
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Oct 18 2020
STATUS
approved