login
A372783
In the ternary expansion of n: keep the initial digit, and then replace 0's with 1's and 1's with 0's.
2
0, 1, 2, 4, 3, 5, 7, 6, 8, 13, 12, 14, 10, 9, 11, 16, 15, 17, 22, 21, 23, 19, 18, 20, 25, 24, 26, 40, 39, 41, 37, 36, 38, 43, 42, 44, 31, 30, 32, 28, 27, 29, 34, 33, 35, 49, 48, 50, 46, 45, 47, 52, 51, 53, 67, 66, 68, 64, 63, 65, 70, 69, 71, 58, 57, 59, 55, 54
OFFSET
0,3
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
FORMULA
a(n) = n iff n belongs to A062318.
EXAMPLE
For n = 42: the ternary expansion of 42 is "1120", so the ternary expansion of a(42) is "1021", and a(42) = 34.
MATHEMATICA
Table[t3=IntegerDigits[n, 3]; fd=First[t3]; tr=Rest[t3]/.{1->0, 0->1}; PrependTo[tr, fd]; FromDigits[tr, 3], {n, 0, 67}] (* James C. McMahon, May 31 2024 *)
PROG
(PARI) a(n) = { my (t = digits(n, 3)); for (i = 2, #t, t[i] = [1, 0, 2][1+t[i]]; ); fromdigits(t, 3); }
CROSSREFS
Cf. A004488, A062318 (fixed points), A115303.
Sequence in context: A372341 A166014 A357527 * A348357 A199779 A374800
KEYWORD
nonn,base,look,easy
AUTHOR
Rémy Sigrist, May 13 2024
STATUS
approved