OFFSET
1,1
EXAMPLE
41 is an item as it generates the Cunningham chain (41, 83, 167), of length 3, that is prime.
MATHEMATICA
aQ[n_] := PrimeQ[Length[NestWhileList[2#+1&, n, PrimeQ]] - 1]; Select[Range[2200], aQ] (* Amiram Eldar, Dec 11 2018 *)
PROG
(Python)
from sympy.ntheory import isprime
def cunningham_chain(p, t):
#it returns the cunningham chain generated by p of type t (1 or 2)
if not(isprime(p)):
raise Exception("Invalid starting number! It must be prime")
if t!=1 and t!=2:
raise Exception("Invalid type! It must be 1 or 2")
elif t==1: k=t
else: k=-1
cunn_ch=[]
cunn_ch.append(p)
while isprime(2*p+k):
p=2*p+k
cunn_ch.append(p)
return(cunn_ch)
from sympy import prime
n=350
r=""
for i in range(1, n):
cunn_ch=(cunningham_chain(prime(i), 1))
lcunn_ch=len(cunn_ch)
if isprime(lcunn_ch):
r += ", "+str(prime(i))
print(r[1:])
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierandrea Formusa, Dec 10 2018
STATUS
approved