OFFSET
0,3
COMMENTS
This sequence is a permutation of the nonnegative numbers.
The inverse sequence, say b, satisfies b(n) = A001202(n+1) for n = 0..1022, but b(1023) = 19 whereas A001202(1024) = 10.
The first known fixed points are: 0, 1, 65010; they all belong to A037308.
This encoding can be applied to any base b > 1 (when b = 2, we obtain the identity function) as well as to the factorial base and to the primorial base.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Rémy Sigrist, Colored logarithmic scatterplot of the first 1000000 terms (where the color is function of the digital sum minus the number of nonleading digits different from 9)
FORMULA
EXAMPLE
For n = 1972:
- the digit 1 is replaced by "01",
- the digit 9 is replaced by "111111111",
- the digit 7 is replaced by "01111111",
- the digit 2 is replaced by "011",
- hence we obtain the binary string "0111111111101111111011",
- and a(1972) = 2096123.
MATHEMATICA
tb=Table[n->PadRight[{0}, n+1, 1], {n, 9}]/.PadRight[{0}, 10, 1]-> PadRight[ {}, 9, 1]; Table[FromDigits[IntegerDigits[n]/.tb//Flatten, 2], {n, 0, 60}] (* Harvey P. Dale, Jul 31 2018 *)
PROG
(PARI) a(n, base=10) = my (b=[], d=digits(n, base)); for (i=1, #d, if (d[i]!=base-1, b=concat(b, 0)); b=concat(b, vector(d[i], k, 1))); fromdigits(b, 2)
/* inverse */ b(n, base=10) = my (v=0, p=1); while (n, my (d = min(valuation(n+1, 2), base-1)); v += p * d; n \= 2^min(base-1, 1+d); p *= base); v
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Jun 02 2018
STATUS
approved