login
Starting with n, repeatedly sum prime factors (with multiplicity) until reaching 0 or a fixed point. Then a(n) is the fixed point (or 0).
13

%I #48 Nov 03 2023 06:51:10

%S 0,2,3,4,5,5,7,5,5,7,11,7,13,5,5,5,17,5,19,5,7,13,23,5,7,5,5,11,29,7,

%T 31,7,5,19,7,7,37,7,5,11,41,7,43,5,11,7,47,11,5,7,5,17,53,11,5,13,13,

%U 31,59,7,61,5,13,7,5,5,67,7,5,5,71,7,73,5,13,23,5,5,79,13,7,43,83,5,13

%N Starting with n, repeatedly sum prime factors (with multiplicity) until reaching 0 or a fixed point. Then a(n) is the fixed point (or 0).

%C That is, the sopfr function (see A001414) applied repeatedly until reaching 0 or a fixed point.

%C For n > 1, the sequence reaches a fixed point which is either 4 or a prime.

%C A002217(n) is number of terms in sequence from n to a(n). - _Reinhard Zumkeller_, Apr 08 2003

%C Because sopfr(n) <= n (with equality at 4 and the primes), the first appearance of all primes is in the natural order: 2,3,5,7,11,... . - _Zak Seidov_, Mar 14 2011

%C The terms 0, 2, 3 and 4 occur exactly once, because no number > 5 can have factors that sum to be < 5, and therefore can never enter a trajectory that will drop below 5. - _Christian N. K. Anderson_, May 19 2013

%C For all primes p, where p is contained in A001359, then a(p^2) = p + 2. (A006512). Proof: p^2 has prime factors (p, p). This sums to 2p. 2p has factors (2, p). This sums to p + 2. Since p was the lesser of a twin prime, then p + 2 is the greater of a twin prime. - _Ryan Bresler_, Nov 04 2021

%H Christian N. K. Anderson, <a href="/A029908/b029908.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from T. D. Noe)

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/SumofPrimeFactors.html">Sum of Prime Factors</a>.

%e 20 -> 2+2+5 = 9 -> 3+3 = 6 -> 2+3 = 5, so a(20)=5.

%p f:= proc(n) option remember;

%p if isprime(n) then n

%p else `procname`(add(x[1]*x[2], x = ifactors(n)[2]))

%p fi

%p end proc:

%p f(1):= 0: f(4):= 4:

%p map(f, [$1..100]); # _Robert Israel_, Apr 27 2015

%t ffi[x_] := Flatten[FactorInteger[x]] lf[x_] := Length[FactorInteger[x]] ba[x_] := Table[Part[ffi[x], 2*w-1], {w, 1, lf[x]}] ep[x_] := Table[Part[ffi[x], 2*w], {w, 1, lf[x]}] slog[x_] := slog[x_] := Apply[Plus, ba[x]*ep[x]] Table[FixedPoint[slog, w], {w, 1, 128}]

%t f[n_] := Plus @@ Flatten[ Table[ #[[1]], {#[[2]]}] & /@ FactorInteger@n]; Array[ FixedPoint[f, # ] &, 87] (* _Robert G. Wilson v_, Jan 18 2006 *)

%t fz[n_]:=Plus@@(#[[1]]*#[[2]]&/@FactorInteger@n); Array[FixedPoint[fz,#]&,1000] (* _Zak Seidov_, Mar 14 2011 *)

%o (Python)

%o from sympy import factorint

%o def a(n, pn):

%o if n == pn:

%o return n

%o else:

%o return a(sum(p*e for p, e in factorint(n).items()), n)

%o print([a(i, None) for i in range(1, 100)]) # _Gleb Ivanov_, Nov 05 2021

%Y Cf. A001414 (sum of prime factors of n).

%Y Cf. A081758, A002217, A075860.

%Y Cf. A001414, A056239, A008475, A082081, A082083.

%K nonn

%O 1,2

%A _Dann Toliver_