Cody

# Problem 45367. Sieve of Eratosthenes - 02

Solution 2192416

Submitted on 4 Apr 2020
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   Fail
assert(isequal(sieve(50),primes(50)))

Index exceeds the number of array elements (0). Error in sieve (line 7) a = [a l(1)]; Error in Test1 (line 1) assert(isequal(sieve(50),primes(50)))

2   Fail
assert(isequal(sieve(5000),primes(5000)))

y = Columns 1 through 30 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 Columns 31 through 51 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233

Assertion failed.

3   Fail
assert(isequal(sieve(19),primes(19)))

Index exceeds the number of array elements (0). Error in sieve (line 7) a = [a l(1)]; Error in Test3 (line 1) assert(isequal(sieve(19),primes(19)))

4   Fail
assert(isequal(sieve(6660),primes(6660)))

y = Columns 1 through 30 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 Columns 31 through 51 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233

Assertion failed.

5   Fail
assert(isequal(sieve(20050),primes(20050)))

y = Columns 1 through 30 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 Columns 31 through 51 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233

Assertion failed.

6   Fail
assert(isequal(sieve(200500),primes(200500)))

y = Columns 1 through 30 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 Columns 31 through 51 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233

Assertion failed.

7   Pass
filetext = fileread('sieve.m'); assert(isempty(strfind(filetext, 'primes')),'primes() forbidden') assert(isempty(strfind(filetext, 'isprime')),'isprime() forbidden')

### Community Treasure Hunt

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

Start Hunting!