Cody

Solution 1317333

Submitted on 27 Oct 2017 by David Verrelli
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
x = 0; y_correct = 2; assert(isequal(nearestprime(x),y_correct))

p = 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 ans = 2

2   Pass
x = 5; y_correct = 5; assert(isequal(nearestprime(x),y_correct))

p = 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 ans = 5

3   Pass
x = 100; y_correct = 101; assert(isequal(nearestprime(x),y_correct))

p = 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 46 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 ans = 101

4   Pass
x = 500; y_correct = 499; assert(isequal(nearestprime(x),y_correct))

p = Columns 1 through 30 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 Column 31 599 ans = 499

5   Pass
x = 911; y_correct = 911; assert(isequal(nearestprime(x),y_correct))

p = Columns 1 through 15 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 Columns 16 through 29 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 ans = 911

6   Pass
x = 2500; y_correct = 2503; assert(isequal(nearestprime(x),y_correct))

p = Columns 1 through 15 2411 2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521 2531 2539 2543 Columns 16 through 21 2549 2551 2557 2579 2591 2593 ans = 2503

7   Pass
x = 8000; y_correct = 7993; assert(isequal(nearestprime(x),y_correct))

p = Columns 1 through 15 7901 7907 7919 7927 7933 7937 7949 7951 7963 7993 8009 8011 8017 8039 8053 Columns 16 through 21 8059 8069 8081 8087 8089 8093 ans = 7993

8   Pass
x = 100000; y_correct = 100003; assert(isequal(nearestprime(x),y_correct))

p = 99901 99907 99923 99929 99961 99971 99989 99991 100003 100019 100043 100049 100057 100069 ans = 100003

9   Pass
x = 1300000; y_correct = 1299989; assert(isequal(nearestprime(x),y_correct))

p = 1299917 1299919 1299941 1299953 1299979 1299989 1300021 1300027 1300031 1300051 1300073 1300097 ans = 1299989

10   Pass
x = 179424710; y_correct = 179424719; assert(isequal(nearestprime(x),y_correct))

p = Columns 1 through 15 179424611 179424617 179424629 179424667 179424671 179424673 179424691 179424697 179424719 179424731 179424743 179424779 179424787 179424793 179424797 Column 16 179424799 ans = 179424719