cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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

Views

Author

Stéphane Rézel, Sep 29 2019

Keywords

Comments

For all numbers n, the iterated map n -> a(n) gives a loop of numbers linked by permutations of their digits, consisting of k-cycles, with k always odd. Indeed, for k even, each iteration divides k by 2. After a few steps, we obtain a fixed point or a loop of 2, 3, 4 or 6, generated respectively by:
- the identity,
- 2 permutations consisting of one, two or three 3-cycle,
- 3 permutations of 7-cycle,
- 4 permutations of 5-cycle,
- 6 permutations of 9-cycle.
Thus, the smallest numbers n giving such loops are respectively 0, 231, 2345671, 23451 and 234567891. There is no step before loop of 6 because the permutation applies directly to all nonzero digits. Also applicable to other bases, the loop length is the least common multiple of multiplicative orders of 2 modulo the different values of k.

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.
		

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