Cody

Solution 1792647

Submitted on 18 Apr 2019 by Adam
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))

M = 0 M = 3 MM = 3 x = 2 M = 7 MM = 3 7 x = 3 M = 31 MM = 3 7 31 x = 4 M = 127 MM = 3 7 31 127 x = 5 y = 3 f = 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))

M = 0 M = 3 MM = 3 x = 2 M = 7 MM = 3 7 x = 3 M = 31 MM = 3 7 31 x = 4 M = 127 MM = 3 7 31 127 x = 5 M = 2047 MM = 3 7 31 127 2047 x = 6 y = 4 f = 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))

M = 0 M = 3 MM = 3 x = 2 M = 7 MM = 3 7 x = 3 M = 31 MM = 3 7 31 x = 4 M = 127 MM = 3 7 31 127 x = 5 M = 2047 MM = 3 7 31 127 2047 x = 6 M = 8191 MM = 3 7 31 127 2047 8191 x = 7 M = 131071 MM = 3 7 31 127 2047 8191 131071 x = 8 y = 5 f = 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))

M = 0 M = 3 MM = 3 x = 2 M = 7 MM = 3 7 x = 3 M = 31 MM = 3 7 31 x = 4 M = 127 MM = 3 7 31 127 x = 5 M = 2047 MM = 3 7 31 127 2047 x = 6 M = 8191 MM = 3 7 31 127 2047 8191 x = 7 M = 131071 MM = 3 7 31 127 2047 8191 131071 x = 8 y = 5 f = 5.2127e-04

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))

M = 0 M = 3 MM = 3 x = 2 M = 7 MM = 3 7 x = 3 M = 31 MM = 3 7 31 x = 4 M = 127 MM = 3 7 31 127 x = 5 M = 2047 MM = 3 7 31 127 2047 x = 6 M = 8191 MM = 3 7 31 127 2047 8191 x = 7 M = 131071 MM = 3 7 31 127 2047 8191 131071 x = 8 M = 524287 MM = 3 7 31 127 2047 8191 131071 524287 x = 9 M = 8388607 MM = 3 7 31 127 2047 8191 131071 524287 8388607 x = 10 y = 7 f = 8.9174e-05