A029908 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).
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, 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, 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
Offset: 1
Keywords
Examples
20 -> 2+2+5 = 9 -> 3+3 = 6 -> 2+3 = 5, so a(20)=5.
Links
- Christian N. K. Anderson, Table of n, a(n) for n = 1..10000 (first 1000 terms from T. D. Noe)
- Eric Weisstein's World of Mathematics, Sum of Prime Factors.
Crossrefs
Programs
-
Maple
f:= proc(n) option remember; if isprime(n) then n else `procname`(add(x[1]*x[2], x = ifactors(n)[2])) fi end proc: f(1):= 0: f(4):= 4: map(f, [$1..100]); # Robert Israel, Apr 27 2015
-
Mathematica
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}] f[n_] := Plus @@ Flatten[ Table[ #[[1]], {#[[2]]}] & /@ FactorInteger@n]; Array[ FixedPoint[f, # ] &, 87] (* Robert G. Wilson v, Jan 18 2006 *) fz[n_]:=Plus@@(#[[1]]*#[[2]]&/@FactorInteger@n); Array[FixedPoint[fz,#]&,1000] (* Zak Seidov, Mar 14 2011 *)
-
Python
from sympy import factorint def a(n, pn): if n == pn: return n else: return a(sum(p*e for p, e in factorint(n).items()), n) print([a(i, None) for i in range(1, 100)]) # Gleb Ivanov, Nov 05 2021
Comments