Cody

Problem 2910. Mersenne Primes vs. All Primes

Solution 2906182

Submitted on 3 Sep 2020 by Schiefermüller Lukas
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 1e2; y_correct = 3; f_correct = 3/25; [y,f] = Mersenne_prime_comp(n); assert(isequal(y,y_correct)) assert(isequal(f,f_correct))

3.0000 0.1200

2   Pass
n = 1e3; y_correct = 4; f_correct = 0.023809523809524; [y,f] = Mersenne_prime_comp(n); assert(isequal(y,y_correct)) assert(abs(f-f_correct)<(10*eps))

4.0000 0.0238

3   Pass
n = 1e4; y_correct = 5; f_correct = 0.004068348250610; [y,f] = Mersenne_prime_comp(n); assert(isequal(y,y_correct)) assert(abs(f-f_correct)<(10*eps))

5.0000 0.0041

4   Pass
n = 1e5; y_correct = 5; f_correct = 5.212677231025855e-04; [y,f] = Mersenne_prime_comp(n); assert(isequal(y,y_correct)) assert(abs(f-f_correct)<(10*eps))

5.0000 0.0005

5   Pass
n = 1e6; y_correct = 7; f_correct = 8.917424647761727e-05; [y,f] = Mersenne_prime_comp(n); assert(isequal(y,y_correct)) assert(abs(f-f_correct)<(10*eps))

7.0000 0.0001

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!