Mersenne Primes vs. All Primes - MATLAB Cody - MATLAB Central

Problem 2910. Mersenne Primes vs. All Primes

Difficulty:Rate

A Mersenne prime (M) is a prime number of the form M = 2^p - 1, where p is another prime number. Problem 525 asks the user to determine if a number is a Mersenne prime. In this problem, you are tasked with returning the number of primes numbers below the input number, n, that are Mersenne primes and the fraction of all primes below that input number that the Mersenne primes represent.

For example, for n = 100, there are 25 primes numbers: 2, 3, 5, 7, ..., 89, 97. As far as Mersenne primes go, there are only three that are less than 100: 2^2 - 1 = 3, 2^3 - 1 = 7, and 2^5 - 1 = 31. The corresponding fraction would be 3/25.

Solution Stats

38.53% Correct | 61.47% Incorrect
Last Solution submitted on Feb 25, 2025

Problem Comments

Solution Comments

Show comments
Primes and Rough Numbers, Basic ideas
What is a rough number? What can they be used...
3
5

Problem Recent Solvers722

Suggested Problems

More from this Author139

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page