Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 6 - Functions - Programming Exercises - Page 209: 6.26

Answer

code

Work Step by Step

# 6.26 (Mersenne prime) A prime number is called a Mersenne prime if it can be written # in the form $2^p-1$ for some positive integer p. Write a program that finds all # Mersenne primes with and displays the output as follows: # p 2^p - 1 # 2 3 # 3 7 # 5 31 # ... from CH6Module import MyFunctions print("P", " ", "2^p - 1") for p in range(2, 31 + 1): i = 2 ** p - 1 # Display each number in five positions if MyFunctions.isPrime(i): print(str(p) + "\t\t" + str(i))
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.