OFFSET
1,8
COMMENTS
The factorial numbers are fixed points of the map, since f(k!) = 1 for all k >= 0. Therefore they are arbitrarily assigned the value a(k!) = 0.
Each number n starts a chain of a(n) integers: n, n/f(n), (n/f(n))/f(n/f(n)), ..., of them the first a(n)-1 integers are factorial-base Niven numbers (A118363).
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
a(8) = 2 since 8/f(8) = 4 and 4/f(4) = 2 is a factorial number that is reached after 2 iterations.
a(27) = 3 since 27/f(27) = 9, 9/f(9) = 3 and 3/f(3) = 3/2 is a noninteger that is reached after 3 iterations.
MATHEMATICA
fdigsum[n_] := Module[{k = n, m = 2, r, s = 0}, While[{k, r} = QuotientRemainder[k, m]; k != 0 || r != 0, s += r; m++]; s]; a[n_] := a[n] = Module[{s = fdigsum[n]}, If[s == 1, 0, If[!Divisible[n, s], 1, 1 + a[n/s]]]]; Array[a, 100]
PROG
(PARI) fdigsum(n) = {my(k = n, m = 2, r, s = 0); while([k, r] = divrem(k, m); k != 0 || r != 0, s += r; m++); s; }
a(n) = {my(f = fdigsum(n)); if(f == 1, 0, if(n % f, 1, 1 + a(n/f))); }
(Python)
def f(n, p=2): return n if n<p else f(n//p, p+1) + n%p
def a(n): return 0 if (fn:=f(n)) == 1 else (1 if n%fn else 1 + a(n//fn))
print([a(n) for n in range(1, 101)]) # Michael S. Branicky, Oct 27 2024
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
Amiram Eldar, Oct 27 2024
STATUS
approved