OFFSET
1,1
COMMENTS
This is based on a modification of Euclid's proof of the infinitude of primes.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Alexander Bogomolny, Infinitely many proofs that there are infinitely many primes
Alexander Bogomolny, Python program
Des MacHale, Infinitely many proofs that there are infinitely many primes, Math. Gazette, 97 (No. 540, 2013), 495-498.
EXAMPLE
This is a modification of Euclid's proof of the infinitude of primes. Instead of 1, add a prime but exclude it from the product. For example, primes: 3+2, 3*5+2, 3*5*7+2, but 3*5*7*11+2 is composite. This is the 4 at the beginning of the sequence.
MAPLE
P:= select(isprime, [2, seq(i, i=3..10^5, 2)]):
f:= proc(n) local j, p, t;
t:= 1:
for j from 1 do
if j <> n then t:= t*P[j] fi;
if not isprime(t+P[n]) then if j >= n then return j-1 else return j fi fi;
od
end proc:
map(f, [$1..100]); # Robert Israel, May 08 2024
PROG
(Python) see Python program link
(PARI) iscomposite(n) = (n != 1) && !isprime(n);
val(j, n) = my(p = prod(k=1, j, prime(k))); if (n<=j, p = p/prime(n)); p + prime(n);
a(n) = my(j = 1, prev = 0, nb = 1, newv); while (!iscomposite(newv = val(j, n)), if (newv != prev, nb++); j++; prev = newv; ); if (n==1, nb-1, nb); \\ Michel Marcus, Apr 15 2014; corrected May 09 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Alexander Bogomolny, Feb 04 2014
EXTENSIONS
New name, data corrected and extended by Michel Marcus, Apr 15 2014
STATUS
approved