login
A325984
Lexicographically earliest sequence of distinct nonnegative terms such that for any n >= 0, the sum of digits of n in base 2 equals the sum of digits of a(n) in base 3.
2
0, 1, 3, 2, 9, 4, 6, 5, 27, 10, 12, 7, 18, 11, 13, 8, 81, 28, 30, 15, 36, 19, 21, 14, 54, 29, 31, 16, 33, 20, 22, 17, 243, 82, 84, 37, 90, 39, 45, 24, 108, 55, 57, 32, 63, 34, 38, 23, 162, 83, 85, 40, 87, 42, 46, 25, 91, 48, 56, 35, 58, 41, 43, 26, 729, 244
OFFSET
0,3
COMMENTS
This sequence is a permutation of the nonnegative integers, with inverse A325985.
The first known fixed points are: 0, 1, 6 and 129936.
We can generalize this sequence for any pair of bases > 1, say u and v:
- let f_{u,v} be the lexicographically earliest sequence of distinct nonnegative terms such that for any n >= 0, the sum of digits of n in base u equals the sum of digits of f_{u,v}(n) in base v,
- in particular f_{2,3} = a (this sequence) and f_{3,2} = A325985,
- f_{u,v} is a permutation of the nonnegative integers, with inverse f_{v,u},
- f_{u,v}(u^k) = v^k for any k >= 0,
- f_{u,u} is the identity function,
- f_{u,v} o f_{v,w} = f_{u,w} (where o denotes function composition).
FORMULA
a(2^k) = 3^k for any k >= 0.
A000120(n) = A053735(a(n)).
a(A018900(k)) = A055235(k-1) for any k > 0.
EXAMPLE
The first terms, alongside the binary representation of n and the ternary representation of a(n), are:
n a(n) bin(n) ter(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 3 10 10
3 2 11 2
4 9 100 100
5 4 101 11
6 6 110 20
7 5 111 12
8 27 1000 1000
9 10 1001 101
10 12 1010 110
11 7 1011 21
12 18 1100 200
13 11 1101 102
14 13 1110 111
15 8 1111 22
16 81 10000 10000
MATHEMATICA
a[0] = 0; a[n_] := a[n] = Module[{s = DigitCount[n, 2, 1], k = 1}, While[! FreeQ[Array[a, n - 1], k] || Plus @@ IntegerDigits[k, 3] != s, k++]; k]; Array[a, 66, 0] (* Amiram Eldar, Jul 25 2023 *)
PROG
(PARI) See Links section.
CROSSREFS
Sequence in context: A134562 A090639 A294370 * A178774 A320273 A266636
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, May 30 2019
STATUS
approved