cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A320342 #41 Jan 27 2019 08:58:29
%S A320342 47,7,47,7,47,13,17,19,47,59,31,37,167,43,47,107,59,61,67,71,73,79,
%T A320342 167,2879,97,101,103,107,109,227,127,263,137,139,149,151,157,163,167,
%U A320342 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 A320342 Maximum term in Cunningham chain of the first kind generated by the n-th prime.
%C A320342 No term is a Sophie Germain prime.
%C A320342 A181697 is the sequence of the lengths of the chains in the name.
%e A320342 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 A320342 a[n_] := NestWhile[2#+1&, n, PrimeQ, 1, Infinity, -1]; a/@Prime@Range@70  (* _Amiram Eldar_, Dec 11 2018 *)
%o A320342 (Python)
%o A320342 def cunningham_chain(p,t):
%o A320342     # returns the Cunningham chain generated by p of type t (1 or 2)
%o A320342     from sympy.ntheory import isprime
%o A320342     if not(isprime(p)):
%o A320342         raise Exception("Invalid starting number! It must be prime")
%o A320342     if t!=1 and t!=2:
%o A320342         raise Exception("Invalid type! It must be 1 or 2")
%o A320342     elif t==1: k=t
%o A320342     else: k=-1
%o A320342     cunn_ch=[]
%o A320342     cunn_ch.append(p)
%o A320342     while isprime(2*p+k):
%o A320342         p=2*p+k
%o A320342         cunn_ch.append(p)
%o A320342     return(cunn_ch)
%o A320342 from sympy import prime
%o A320342 n=71
%o A320342 r=""
%o A320342 for i in range(1,n):
%o A320342     cunn_ch=(cunningham_chain(prime(i),1))
%o A320342     last_item=cunn_ch[-1]
%o A320342     r += ","+str(last_item)
%o A320342 print(r[1:])
%Y A320342 Cf. A181697.
%K A320342 nonn
%O A320342 1,1
%A A320342 _Pierandrea Formusa_, Dec 10 2018