login
a(n) is the number of distinct terms reached by iterating the function f(x) = 2 + A008472(x), starting from x=n.
0

%I #12 Dec 12 2024 23:16:25

%S 3,2,4,1,3,4,3,2,3,4,7,4,6,8,5,2,7,4,6,4,5,6,5,4,4,8,4,8,5,5,4,2,3,6,

%T 9,4,6,6,5,4,7,9,6,6,5,5,5,4,4,4,7,8,6,4,5,8,5,4,7,5,6,10,5,2,5,5,10,

%U 6,9,3,7,4,6,8,5,6,5,5,5,4,4,6,6,9,5,6,7,6,8,5,7,5,5,8,9,4,4,8,3,4

%N a(n) is the number of distinct terms reached by iterating the function f(x) = 2 + A008472(x), starting from x=n.

%C 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.

%C The set A(n) contains either the fixed point 4 or a cyclic component {5,7,9}.

%e For n=33, 33->16->4->4-> ... and 4 is a fixed point, then a(n)= number of distinct terms = 3.

%e 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.

%p f:= proc(n)

%p add( d, d= numtheory[factorset](n)):

%p end proc: f(1) := 0:

%p g:= proc(n)

%p 2 + f(n)

%p end proc:

%p a:= proc(n)

%p local k, result:

%p k := 1:

%p result := n:

%p while not (result = 4 or result = 5 or result = 7 or result = 9) do

%p result := g(result):

%p k := k + 1:

%p end do:

%p if result = 5 or result = 7 or result = 9 then

%p return k + 2;

%p else

%p return k:

%p end if

%p end proc:

%p map(a, [$1..100]);

%t a[n_] := -1 + Length@ NestWhileList[2 + If[# == 1, 0, Total[FactorInteger[#][[;; , 1]]]] &, n, UnsameQ, All]; Array[a, 100] (* _Amiram Eldar_, Nov 26 2024 *)

%o (Python)

%o from sympy import factorint

%o def a(n):

%o reach = set()

%o while n not in reach:

%o reach.add(n)

%o n = 2 + sum(factorint(n))

%o return len(reach)

%o print([a(n) for n in range(1, 101)]) # _Michael S. Branicky_, Nov 26 2024

%Y Cf. A008472.

%K nonn

%O 1,1

%A _Rafik Khalfi_, Nov 25 2024