OFFSET
1,2
COMMENTS
This sequence is a self-inverse permutation of the natural numbers, with fixed points A031448.
We can build an analog of this sequence for any base b > 1:
- let s_b be the sum of digits in base b,
- let l_b be the number of digits in base b,
- let f_b be the lexicographically earliest sequence of distinct positive terms such that, for any n > 0, s_b(n) = 1 + (b-1) * l_b(a(n)) - s_b(a(n)),
- in particular, f_2 = a (this sequence),
- f_b is a self-inverse permutation of the natural numbers,
- l_b(n) = l_b(f_b(n)) for any n > 0,
- f_b(b^k) = b^(k+1) - 1 for any k >= 0,
- see also scatterplots of f_3 and f_10 in Links section.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..8191
Rémy Sigrist, PARI program for A298847
Rémy Sigrist, Colored scatterplot of the first 2^16 - 1 terms (where the color is function of the Hamming weight of n)
Rémy Sigrist, Scatterplot of the first 3^9 - 1 terms of f_3
Rémy Sigrist, Scatterplot of the first 10^4 - 1 terms of f_10
FORMULA
EXAMPLE
The first terms, alongside the binary representations of n and of a(n), are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
1 1 1 1
2 3 10 11
3 2 11 10
4 7 100 111
5 5 101 101
6 6 110 110
7 4 111 100
8 15 1000 1111
9 11 1001 1011
10 13 1010 1101
11 9 1011 1001
12 14 1100 1110
13 10 1101 1010
14 12 1110 1100
15 8 1111 1000
PROG
(PARI) See Links section.
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 27 2018
STATUS
approved