Cody

Problem 44352. The Top 5 Primes

Solution 2121722

Submitted on 8 Feb 2020 by Eric Mueller
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
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','top5primes.m')

2   Pass
x = 1:10; y_correct = [7 5 3 2 NaN]; assert(isequaln(top5primes(x),y_correct))

r = 1 c = 10 a = 2 a = 3 a = 4 a = 5 a = 6

3   Pass
x = (1:2:100).'; y_correct = [97 89 83 79 73].'; assert(isequaln(top5primes(x),y_correct))

r = 50 c = 1 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 7 a = 8 a = 9 a = 10 a = 11 a = 12 a = 13 a = 14 a = 15 a = 16 a = 17 a = 18 a = 19 a = 20 a = 21 a = 22 a = 23 a = 24 a = 25 y = 97 89 83 79 73

4   Pass
x = [17 6 3 13 8 17 1 2 5 5 3 7 7 11 2 31 7 6]; y_correct = [31 11 17 17 7 7 13 3 5 7 2 3 5 NaN 2]; assert(isequaln(top5primes(x),y_correct))

r = 6 c = 3 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6

5   Pass
x = interp1(magic(30).',1:5).'; y_correct = [877 733 863 719 881 829 701 751 173 769 797 139 59 157 29 89 107 43 109 13 73 NaN 11 61 NaN]; assert(isequaln(top5primes(x),y_correct))

r = 30 c = 5 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 7 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 y = 877 733 863 719 881 829 701 751 173 769 797 139 59 157 29 89 107 43 109 13 73 NaN 11 61 NaN

6   Pass
rng(0); x = reshape(randperm(200,180),36,5); y_correct = [163 181 173 197 193 71 179 149 191 157 23 167 113 139 151 19 131 101 83 137 NaN 109 67 73 127]; assert(isequaln(top5primes(x),y_correct))

r = 36 c = 5 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 7 a = 8 a = 9 a = 10 a = 11 a = 12 a = 13 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 7 a = 8 a = 9 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 7 a = 8 a = 9 a = 10 a = 11 a = 1 a = 2 a = 3 a = 4 a = 5 a = 6 a = 7 a = 8 a = 9 a = 10 a = 11 y = 163 181 173 197 193 71 179 149 191 157 23 167 113 139 151 19 131 101 83 137 NaN 109 67 73 127