login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Maximum term in Cunningham chain of the first kind generated by the n-th prime.
0

%I #41 Jan 27 2019 08:58:29

%S 47,7,47,7,47,13,17,19,47,59,31,37,167,43,47,107,59,61,67,71,73,79,

%T 167,2879,97,101,103,107,109,227,127,263,137,139,149,151,157,163,167,

%U 347,2879,181,383,193,197,199,211,223,227,229,467,479,241,503,257,263,269,271,277,563,283,587,307,311,313,317,331,337,347,349

%N Maximum term in Cunningham chain of the first kind generated by the n-th prime.

%C No term is a Sophie Germain prime.

%C A181697 is the sequence of the lengths of the chains in the name.

%e a(1)=47 as prime(1)=2 and the Cunningham chain generated by 2 is (2,5,11,23,47), with maximum item 47.

%t a[n_] := NestWhile[2#+1&, n, PrimeQ, 1, Infinity, -1]; a/@Prime@Range@70 (* _Amiram Eldar_, Dec 11 2018 *)

%o (Python)

%o def cunningham_chain(p,t):

%o # returns the Cunningham chain generated by p of type t (1 or 2)

%o from sympy.ntheory import isprime

%o if not(isprime(p)):

%o raise Exception("Invalid starting number! It must be prime")

%o if t!=1 and t!=2:

%o raise Exception("Invalid type! It must be 1 or 2")

%o elif t==1: k=t

%o else: k=-1

%o cunn_ch=[]

%o cunn_ch.append(p)

%o while isprime(2*p+k):

%o p=2*p+k

%o cunn_ch.append(p)

%o return(cunn_ch)

%o from sympy import prime

%o n=71

%o r=""

%o for i in range(1,n):

%o cunn_ch=(cunningham_chain(prime(i),1))

%o last_item=cunn_ch[-1]

%o r += ","+str(last_item)

%o print(r[1:])

%Y Cf. A181697.

%K nonn

%O 1,1

%A _Pierandrea Formusa_, Dec 10 2018