OFFSET
1,1
COMMENTS
a(n)= The number of distinct elements in the set A(n)={f^{k}(n);k>=0}, where f^{k} is the k-th iteration of f.
The set A(n) contains either the fixed point 4 or a cyclic component {5,7,9}.
EXAMPLE
For n=33, 33->16->4->4-> ... and 4 is a fixed point, then a(n)= number of distinct terms = 3.
For n=66, 66->18->7->9->5->7 ... and {5,7,9} is a cyclic component, then a(n)= number of distinct terms = 5.
MAPLE
f:= proc(n)
add( d, d= numtheory[factorset](n)):
end proc: f(1) := 0:
g:= proc(n)
2 + f(n)
end proc:
a:= proc(n)
local k, result:
k := 1:
result := n:
while not (result = 4 or result = 5 or result = 7 or result = 9) do
result := g(result):
k := k + 1:
end do:
if result = 5 or result = 7 or result = 9 then
return k + 2;
else
return k:
end if
end proc:
map(a, [$1..100]);
MATHEMATICA
a[n_] := -1 + Length@ NestWhileList[2 + If[# == 1, 0, Total[FactorInteger[#][[;; , 1]]]] &, n, UnsameQ, All]; Array[a, 100] (* Amiram Eldar, Nov 26 2024 *)
PROG
(Python)
from sympy import factorint
def a(n):
reach = set()
while n not in reach:
reach.add(n)
n = 2 + sum(factorint(n))
return len(reach)
print([a(n) for n in range(1, 101)]) # Michael S. Branicky, Nov 26 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Rafik Khalfi, Nov 25 2024
STATUS
approved