OFFSET
1,2
COMMENTS
Will all prime numbers appear in this sequence?
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(7)=20, a(8) = least prime factor of 20 = 2.
a(9)=11, a(10) = 11+10 = 21.
MAPLE
f:= proc(n) local q; option remember;
q:= procname(n-1);
if isprime(q) then q+n
else min(numtheory:-factorset(q))
fi
end proc:
f(1):= 1: f(2):=3:
map(f, [$1..100]); # Robert Israel, Oct 25 2019
MATHEMATICA
a[1] = 1; a[n_] := a[n] = If[CompositeQ[a[n - 1]], FactorInteger[a[n - 1]][[1, 1]], a[n - 1] + n]; Array[a, 100] (* Amiram Eldar, Oct 23 2019 *)
nxt[{n_, a_}]:={n+1, If[CompositeQ[a], FactorInteger[a][[1, 1]], a+n+1]}; NestList[nxt, {1, 1}, 70] [[;; , 2]] (* Harvey P. Dale, Oct 15 2023 *)
PROG
(PARI) for (n=1, 71, print1 (v=if (n==1, 1, bigomega(f=factor(v))>1, f[1, 1], v+n) ", ")) \\ Rémy Sigrist, Oct 23 2019
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Ali Sada, Oct 22 2019
STATUS
approved