OFFSET
1,1
COMMENTS
Are there any repeated terms other than a(1) = a(2) = 2, a(3) = a(5) = 3, a(4) = a(7) = 5 and a(6) = a(10) = 13?
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..160
EXAMPLE
2 - 1 = 1 and 2 + 1 = 3 are both noncomposites.
2*2 - 1 = 3 and 2*2 + 1 = 5 are both primes.
2*2*3 - 1 = 11 and 2*2*3 + 1 = 13 are both primes.
2*2*3*5 - 1 = 59 and 2*2*3*5 + 1 = 61 are both primes.
MAPLE
R:= 2: s:= 2:
for i from 2 to 60 do
p:= 1:
do
p:= nextprime(p);
if isprime(p*s-1) and isprime(p*s+1) then R:= R, p; s:= p*s; break fi;
od od:
R;
MATHEMATICA
a[1] = 2; a[n_] := a[n] = Module[{r = Product[a[k], {k, 1, n - 1}], p = 2}, While[! PrimeQ[r*p - 1] || ! PrimeQ[r*p + 1], p = NextPrime[p]]; p]; Array[a, 55] (* Amiram Eldar, Jan 19 2023 *)
PROG
(Python)
from itertools import islice
from sympy import isprime, nextprime
def agen(): # generator of terms
s = 2; yield 2
while True:
p = 2
while True:
if isprime(s*p-1) and isprime(s*p+1):
yield p; s *= p; break
p = nextprime(p)
print(list(islice(agen(), 55))) # Michael S. Branicky, Jan 19 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Jan 19 2023
STATUS
approved