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.

A329424 Starting from n: as long as the decimal representation starts with a positive multiple of 3, divide the largest such prefix by 3; a(n) corresponds to the final value.

Original entry on oeis.org

0, 1, 2, 1, 4, 5, 2, 7, 8, 1, 10, 11, 4, 13, 14, 5, 16, 17, 2, 19, 20, 7, 22, 23, 8, 25, 26, 1, 28, 29, 10, 11, 4, 11, 14, 5, 4, 17, 2, 13, 40, 41, 14, 43, 44, 5, 46, 47, 16, 49, 50, 17, 52, 53, 2, 55, 56, 19, 58, 59, 20, 7, 22, 7, 8, 25, 22, 1, 28, 23, 70, 71
Offset: 0

Views

Author

Rémy Sigrist, Nov 30 2019

Keywords

Comments

As long as we have a number whose decimal representation is the concatenation of a positive multiple of 3, say u, and a minimal string possibly empty, say v, we replace this number with the concatenation of u/3 and v; eventually none of the prefixes will be a positive multiple of 3.

Examples

			For n = 1011:
- 1011 gives 1011/3 = 337,
- 337 gives 33/3 followed by 7 = 117,
- 117 gives 117/3 = 39,
- 39 gives 39/3 = 13,
- neither 1 nor 13 is a multiple of 3, so a(1011) = 13.
		

Crossrefs

See A327539 for similar sequences.

Programs

  • PARI
    t(n) = if (n==0, 0, n%3==0, n/3, 10*t(n\10)+(n%10))
    a(n) = while (n!=n=t(n),); n

Formula

a(n) <= n.