A327886 Digits d in decimal expansion of n replaced with d-th digit of n (keeping the digits 0). If n does not have enough digits to index, the indexing resumes at the first digit of n as many times as necessary to find the substitution digit. Leading zeros are erased unless the result is 0.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 14, 11, 16, 11, 18, 11, 0, 12, 22, 32, 44, 52, 66, 72, 88, 92, 30, 33, 32, 33, 34, 33, 36, 33, 38, 33, 0, 14, 22, 34, 44, 54, 66, 74, 88, 94, 50, 55, 52, 55, 54, 55, 56, 55, 58, 55, 0, 16, 22, 36, 44, 56, 66, 76
Offset: 0
Examples
For n=23, the digit 2 is replaced by three, because it is the second digit of n. Next, the digit 3 cannot be replaced directly because n has no third digit. After counting the first two digits of n, the indexing resumes at the first digit of n which corresponds here to the third ordinal: the digit 3 is thus replaced by two. In summary: a(23) = {2nd digit of n, 1st digit of n} = {3, 2} = 32. a(2056748) = {0, 0, 7, 4, 8, 6, 2} = 74862.
Links
- Stéphane Rézel, Table of n, a(n) for n = 0..10000
Crossrefs
Cf. A002326.
Programs
-
Mathematica
Array[FromDigits@ Map[# /. k_ /; ! IntegerQ@ k -> 0 &, PadRight[#, 9, #][[#]]] &@ IntegerDigits[#] &, 67] (* Michael De Vlieger, Sep 30 2019 *)
-
PARI
a(n) = {if (n==0, return (0)); my(s = Str(n), d=digits(n)); if (#s < 9, my(i=1); while (#s < 9, s = concat(s, d[i]); i++; if (i>#d, i=1))); my(dm = digits(eval(s))); my(ns=""); for (i=1, #d, if (dm[i], ns = concat(ns, dm[dm[i]]), ns = concat(ns, 0));); eval(ns);} \\ Michel Marcus, Sep 30 2019
Comments