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).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
Rémy Sigrist, Colored logarithmic scatterplot of the sequence for n = 0..2^16 (where the color is function of A000120(n)).
Rémy Sigrist, PARI program for A325984.
FORMULA
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
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, May 30 2019
STATUS
approved