OFFSET
0,3
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
LINKS
FORMULA
EXAMPLE
For n = 539:
- the base-4 expansion of 539 is "20123",
- it starts with the digit 2, so we replace 1's by 3's and vice versa,
- so the base-4 expansion of a(539) is "20321", and a(539) = 569.
PROG
(PARI) a(n) = { my (q = digits(n, 4), m = if (#q, [ [0, 1, 3, 2], [0, 3, 2, 1], [0, 2, 1, 3] ][q[1]], [0, 1, 2, 3])); fromdigits(apply (d -> m[1+d], q), 4); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 01 2023
STATUS
approved