Cody

Problem 46624. List the emirps

Solution 3138086

Submitted on 9 Oct 2020 by James
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 = 10; assert(isempty(emirps(n)))

2   Pass
n = 100; y_correct = [13 17 31 37 71 73 79 97]; assert(isequal(emirps(n),y_correct))

3   Pass
n = 1000; y_correct = [13 17 31 37 71 73 79 97 107 113 149 157 167 179 199 311 337 347 359 389 701 709 733 739 743 751 761 769 907 937 941 953 967 971 983 991]; assert(isequal(emirps(n),y_correct))

4   Pass
n = 10007; y = emirps(n); len_correct = 241; yp_correct = [3049 3371 3803 7321 7717 9173 9551 9967]; assert(isequal(length(y),len_correct) && isequal(y(100:20:end),yp_correct))

5   Pass
n = 100000; y = emirps(n); len_correct = 1646; yp_correct = [17417 33287 39827 76607 92993 99401]; assert(isequal(length(y),len_correct) && isequal(y(530:220:end),yp_correct))

6   Pass
n = 1e6; y = emirps(n); sum_correct = 5129429596; len_correct = 11184; assert(isequal(length(y),len_correct) && isequal(sum(y),sum_correct))

Suggested Problems

More from this Author50

Community Treasure Hunt

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

Start Hunting!