OFFSET
0,3
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.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
FORMULA
a(n) <= n.
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Nov 30 2019
STATUS
approved