login
a(n) is the number of distinct terms in the trajectory of n under the map k -> A001222(k)*A001414(k).
0

%I #35 Jul 21 2021 10:01:09

%S 2,1,1,10,1,11,1,9,5,10,1,4,1,9,10,9,1,8,1,2,3,3,1,7,3,2,1,2,1,1,1,8,

%T 2,9,8,6,1,8,9,5,1,7,1,4,3,8,1,10,3,7,6,7,1,5,9,8,5,13,1,11,1,12,10,

%U 13,7,11,1,11,8,8,1,12,1,7,10,9,7,6,1,8,11,10

%N a(n) is the number of distinct terms in the trajectory of n under the map k -> A001222(k)*A001414(k).

%C a(n) is the length of a list derived by recursively taking the sum of prime factors of n multiplied by the number of prime factors of n, appending each term to the list without duplicates until a fixed point is reached.

%H CodeGolf, <a href="https://codegolf.stackexchange.com/q/2263/1422">Calculate an integer sequence derived from prime factors</a>

%e Starting with n = 8, we add it to the list: [8]. There are three prime factors of 8, [2,2,2]. These sum to 6. 6 * 3 = 18. We add 18 to the list: [8, 18]. We then repeat the process with 18 to get [8, 18, 24]. The list grows as follows: [8, 18, 24, 36, 40, 44, 45, 33, 28]. Since 28 results in a number we've already seen, we halt. The number of elements in the list is 9, so a(8) = 9.

%t f[n_] := PrimeOmega[n] * (Plus @@ Times @@@ FactorInteger[n]); a[n_] := -1 + Length @ NestWhileList[f, n, UnsameQ, All]; Array[a, 100] (* _Amiram Eldar_, Jun 27 2021 *)

%o (Haskell)

%o term :: Integer -> Integer

%o term n = genericLength $ term' [n]

%o where

%o term' [] = []

%o term' ns@(n':_)

%o | h `elem` ns = ns

%o | otherwise = term' (h:ns)

%o where

%o h = let pfs = primeFactors n' in sum pfs * genericLength pfs

%o (Python)

%o from sympy import factorint

%o def t(n): f = factorint(n); return sum(f.values())*sum(p*f[p] for p in f)

%o def a(n):

%o iter, seen = n, set()

%o while iter not in seen: iter, seen = t(iter), seen|{iter}

%o return len(seen)

%o print([a(n) for n in range(1, 82)]) # _Michael S. Branicky_, Jun 29 2021

%Y Cf. A001222, A001414.

%K nonn

%O 1,1

%A _Gregory Higley_, Jun 25 2021