A320342 Maximum term in Cunningham chain of the first kind generated by the n-th prime.
47, 7, 47, 7, 47, 13, 17, 19, 47, 59, 31, 37, 167, 43, 47, 107, 59, 61, 67, 71, 73, 79, 167, 2879, 97, 101, 103, 107, 109, 227, 127, 263, 137, 139, 149, 151, 157, 163, 167, 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
Offset: 1
Keywords
Examples
a(1)=47 as prime(1)=2 and the Cunningham chain generated by 2 is (2,5,11,23,47), with maximum item 47.
Crossrefs
Cf. A181697.
Programs
-
Mathematica
a[n_] := NestWhile[2#+1&, n, PrimeQ, 1, Infinity, -1]; a/@Prime@Range@70 (* Amiram Eldar, Dec 11 2018 *)
-
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:])
Comments