Cunningham Chain

A Cunningham chain of length n n is a sequence of prime numbers such that for all 1 < i n 1<i\leq n , p i = 2 p i 1 1 p_i = 2p_{i-1}-1 . For example, the sequence 2 , 3 , 5 2,3,5 is a Cunningham chain of length 3.

Consider the smallest Cunningham chain of length 8. What is its last term?


The answer is 1985902081.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Hasmik Garyaka
Oct 27, 2017
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Python



def cunningham():
     result = list(takewhile(lambda x: x < 20000000, erat3()))  
     for j in range(7):
          print(len(result))
          result1=[]
          for n in result:
               if n>5000000 and prime(2*n-1): result1.append(2*n-1)

               if n%3==2 or n%5==3 or n%7==4:continue
               if 2*n-1 in result:
                   result1.append(2*n-1)
          result=result1
     return result

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...