login
A237196
a(n) = index j of the first composite number in the sequence prime(1)*...*prime(n-1)*prime(n+1)*...*prime(j) + prime(n).
2
4, 5, 7, 1, 4, 1, 5, 1, 1, 2, 1, 1, 9, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 6, 1, 8, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 3, 1, 2, 1, 1, 1, 4, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1
OFFSET
1,1
COMMENTS
This is based on a modification of Euclid's proof of the infinitude of primes.
LINKS
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
Sequence in context: A298982 A112247 A319260 * A322711 A057055 A177883
KEYWORD
nonn
AUTHOR
Alexander Bogomolny, Feb 04 2014
EXTENSIONS
New name, data corrected and extended by Michel Marcus, Apr 15 2014
STATUS
approved