OFFSET
1,1
COMMENTS
No term is a Sophie Germain prime.
A181697 is the sequence of the lengths of the chains in the name.
EXAMPLE
a(1)=47 as prime(1)=2 and the Cunningham chain generated by 2 is (2,5,11,23,47), with maximum item 47.
MATHEMATICA
a[n_] := NestWhile[2#+1&, n, PrimeQ, 1, Infinity, -1]; a/@Prime@Range@70 (* Amiram Eldar, Dec 11 2018 *)
PROG
(Python)
def cunningham_chain(p, t):
# returns the Cunningham chain generated by p of type t (1 or 2)
from sympy.ntheory import isprime
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=71
r=""
for i in range(1, n):
cunn_ch=(cunningham_chain(prime(i), 1))
last_item=cunn_ch[-1]
r += ", "+str(last_item)
print(r[1:])
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierandrea Formusa, Dec 10 2018
STATUS
approved