Question: Write a Visual Studio C++ program to calculate and display all the Mersenne primes from 2 through 1,000,000. Your results should be as presented below,
Write a Visual Studio C++ program to calculate and display all the Mersenne primes from 2 through 1,000,000. Your results should be as presented below, under testing.
Testing:
Mersenne Primes by Colin Goble
n Mersenne Prime
== ==============
2 3
3 7
5 31
7 127
13 8191
17 131071
19 524287
Press q (or any other key) followed by 'Enter' to quit:
As an example, a prime number is represented when n = 5 in the formula 2n 1. 25 is 32, minus 1 is 31. The number 31 is a prime number. Your program should compute the value of 2n 1 for all integers starting at n = 1 and going until at least n = 19. If the result is a prime number, then it is a Mersenne Prime and it should be printed as output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
