Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Euclid proved that if both p and 2**p - 1 are prime then (2**p - 1) * (2**(p-1)) is a perfect number. If p and

Euclid proved that if both p and 2**p - 1 are prime then (2**p - 1) * (2**(p-1)) is a perfect number.

If p and 2**p - 1 are both prime, 2**p - 1 is known as a Mersenne prime.

Euler proved that there is a 1-1 correspondence between Mersenne primes and the even perfect numbers. (It is not known whether there are any odd perfect numbers.) See Wikipedia for details.

Complete this function with a list comprehension. (It's easier than it looks.) Use the answers from previous questions to generate the primes and to test for being prime.

def EuclidEulerPerfectNumbers(k): """ Returns a list of triples of the form ( p, 2**p - 1, perfect ), where p and 2**p - 1 are prime, perfect is the associated perfect number, and p is in range(2, k+1). For example print(EuclidEulerPerfectNumbers(19)) => [(2, 3, 6), (3, 7, 28), (5, 31, 496), (7, 127, 8128), (13, 8191, 33550336), (17, 131071, 8589869056), (19, 524287, 137438691328)] Even though some of the numbers are very large, this takes less than 1 second to run.

""" return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How will Industry 4.0 disrupt conventional HRM?

Answered: 1 week ago