Cody

Solution 1742593

Submitted on 5 Mar 2019 by Martin C.
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))

yl = 0 yr = 0 yl = -1 yr = 1 yl = -2 yr = 2 y = 2

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

y = 5

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

yl = 100 yr = 100 yl = 99 yr = 101 y = 101

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

yl = 500 yr = 500 yl = 499 y = 499

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

y = 911

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

yl = 2500 yr = 2500 yl = 2499 yr = 2501 yl = 2498 yr = 2502 yl = 2497 yr = 2503 y = 2503

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

yl = 8000 yr = 8000 yl = 7999 yr = 8001 yl = 7998 yr = 8002 yl = 7997 yr = 8003 yl = 7996 yr = 8004 yl = 7995 yr = 8005 yl = 7994 yr = 8006 yl = 7993 y = 7993

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

yl = 100000 yr = 100000 yl = 99999 yr = 100001 yl = 99998 yr = 100002 yl = 99997 yr = 100003 y = 100003

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

yl = 1300000 yr = 1300000 yl = 1299999 yr = 1300001 yl = 1299998 yr = 1300002 yl = 1299997 yr = 1300003 yl = 1299996 yr = 1300004 yl = 1299995 yr = 1300005 yl = 1299994 yr = 1300006 yl = 1299993 yr = 1300007 yl = 1299992 yr = 1300008 yl = 1299991 yr = 1300009 yl = 1299990 yr = 1300010 yl = 1299989 y = 1299989

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

yl = 179424710 yr = 179424710 yl = 179424709 yr = 179424711 yl = 179424708 yr = 179424712 yl = 179424707 yr = 179424713 yl = 179424706 yr = 179424714 yl = 179424705 yr = 179424715 yl = 179424704 yr = 179424716 yl = 179424703 yr = 179424717 yl = 179424702 yr = 179424718 yl = 179424701 yr = 179424719 y = 179424719