OFFSET
2,1
COMMENTS
Patrick asked what composite would produce 666 or 313 iterations. Carlos has also been working on the problem and asks if there is a run of 3 primes produced by consecutive composites. So original idea belongs to Patrick. This sequence was calculated by Enoch.
LINKS
Robert Israel, Table of n, a(n) for n = 2..10000
INRIA Algorithms Project, Encyclopedia of Combinatorial Structures 940
FORMULA
Factor n, add n and its prime divisors. Sum = t, t replaces n, repeat until a prime is produced.
EXAMPLE
Starting from 4, 4=2*2, so 4+2+2=8. 8=2*2*2 so 8+2+2+2=14. 14=2*7 so 14+2+7=23, prime is 23 in 3 iterations.
MAPLE
f:= proc(n) option remember; local t;
t:= n + add(f[1]*f[2], f=ifactors(n)[2]);
if isprime(t) then return t
else f(t)
fi;
end proc:
map(f, [$2 .. 100]); # Robert Israel, Jul 24 2015
MATHEMATICA
a[n_] := a[n] = Module[{t, f = FactorInteger[n]}, t = n + f[[All, 1]].f[[All, 2]]; If[PrimeQ[t], Return[t], a[t]]];
Table[a[n], {n, 2, 100}] (* Jean-François Alcover, Sep 16 2022 *)
PROG
(PARI) sfpn(n) = {my(f = factor(n)); n + sum(k=1, #f~, f[k, 1]*f[k, 2]); }
a(n) = {while (! isprime(t=sfpn(n)), n=t); t; } \\ Michel Marcus, Jul 24 2015
KEYWORD
easy,nonn
AUTHOR
EXTENSIONS
Corrected by Michel Marcus and Robert Israel, Jul 24 2015
STATUS
approved