A305493 A binary encoding of the decimal representation of a number: for any number n >= 0, consider its decimal representation and replace each 9 with "111111111" and each other digit d with a "0" followed by d "1"s and interpret the result as a binary string.
0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 2, 5, 11, 23, 47, 95, 191, 383, 767, 1023, 6, 13, 27, 55, 111, 223, 447, 895, 1791, 2047, 14, 29, 59, 119, 239, 479, 959, 1919, 3839, 4095, 30, 61, 123, 247, 495, 991, 1983, 3967, 7935, 8191, 62, 125, 251, 503, 1007, 2015
Offset: 0
Examples
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.
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)
- Index entries for sequences related to decimal expansion of n
- Index entries for sequences that are permutations of the natural numbers
Programs
-
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 *)
-
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
Comments