Cody

Solution 1895619

Submitted on 9 Aug 2019 by Yuumi Ozaki
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))

q = 0 x1 = 0 x2 = 0 y1 = 2 y2 = 2 y = 2

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

q = 0 x1 = 5 x2 = 5 y1 = 5 y2 = 5 y = 5

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

q = 0 x1 = 100 x2 = 100 x = 101 y1 = 101 x1 = 99 q = 1 q = 0 x1 = 98 q = 1 q = 0 x1 = 97 y2 = 97 y = 101

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

q = 0 x1 = 500 x2 = 500 x = 501 q = 1 q = 0 x = 502 q = 1 q = 0 x = 503 y1 = 503 x1 = 499 y2 = 499 y = 499

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

q = 0 x1 = 911 x2 = 911 y1 = 911 y2 = 911 y = 911

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

q = 0 x1 = 2500 x2 = 2500 x = 2501 q = 1 q = 0 x = 2502 q = 1 q = 0 x = 2503 y1 = 2503 x1 = 2499 q = 1 q = 0 x1 = 2498 q = 1 q = 0 x1 = 2497 q = 1 q = 0 x1 = 2496 q = 1 q = 0 x1 = 2495 q = 1 q = 0 x1 = 2494 q = 1 q = 0 x1 = 2493 q = 1 q = 0 x1 = 2492 q = 1 q = 0 x1 = 2491 q = 1 q = 0 x1 = 2490 q = 1 q = 0 x1 = 2489 q = 1 q = 0 x1 = 2488 q = 1 q = 0 x1 = 2487 q = 1 q = 0 x1 = 2486 q = 1 q = 0 x1 = 2485 q = 1 q = 0 x1 = 2484 q = 1 q = 0 x1 = 2483 q = 1 q = 0 x1 = 2482 q = 1 q = 0 x1 = 2481 q = 1 q = 0 x1 = 2480 q = 1 q = 0 x1 = 2479 q = 1 q = 0 x1 = 2478 q = 1 q = 0 x1 = 2477 y2 = 2477 y = 2503

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

q = 0 x1 = 8000 x2 = 8000 x = 8001 q = 1 q = 0 x = 8002 q = 1 q = 0 x = 8003 q = 1 q = 0 x = 8004 q = 1 q = 0 x = 8005 q = 1 q = 0 x = 8006 q = 1 q = 0 x = 8007 q = 1 q = 0 x = 8008 q = 1 q = 0 x = 8009 y1 = 8009 x1 = 7999 q = 1 q = 0 x1 = 7998 q = 1 q = 0 x1 = 7997 q = 1 q = 0 x1 = 7996 q = 1 q = 0 x1 = 7995 q = 1 q = 0 x1 = 7994 q = 1 q = 0 x1 = 7993 y2 = 7993 y = 7993

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

q = 0 x1 = 100000 x2 = 100000 x = 100001 q = 1 q = 0 x = 100002 q = 1 q = 0 x = 100003 y1 = 100003 x1 = 99999 q = 1 q = 0 x1 = 99998 q = 1 q = 0 x1 = 99997 q = 1 q = 0 x1 = 99996 q = 1 q = 0 x1 = 99995 q = 1 q = 0 x1 = 99994 q = 1 q = 0 x1 = 99993 q = 1 q = 0 x1 = 99992 q = 1 q = 0 x1 = 99991 y2 = 99991 y = 100003

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

q = 0 x1 = 1300000 x2 = 1300000 x = 1300001 q = 1 q = 0 x = 1300002 q = 1 q = 0 x = 1300003 q = 1 q = 0 x = 1300004 q = 1 q = 0 x = 1300005 q = 1 q = 0 x = 1300006 q = 1 q = 0 x = 1300007 q = 1 q = 0 x = 1300008 q = 1 q = 0 x = 1300009 q = 1 q = 0 x = 1300010 q = 1 q = 0 x = 1300011 q = 1 q = 0 x = 1300012 q = 1 q = 0 x = 1300013 q = 1 q = 0 x = 1300014 q = 1 q = 0 x = 1300015 q = 1 q = 0 x = 1300016 q = 1 q = 0 x = 1300017 q = 1 q = 0 x = 1300018 q = 1 q = 0 x = 1300019 q = 1 q = 0 x = 1300020 q = 1 q = 0 x = 1300021 y1 = 1300021 x1 = 1299999 q = 1 q = 0 x1 = 1299998 q = 1 q = 0 x1 = 1299997 q = 1 q = 0 x1 = 1299996 q = 1 q = 0 x1 = 1299995 q = 1 q = 0 x1 = 1299994 q = 1 q = 0 x1 = 1299993 q = 1 q = 0 x1 = 1299992 q = 1 q = 0 x1 = 1299991 q = 1 q = 0 x1 = 1299990 q = 1 q = 0 x1 = 1299989 y2 = 1299989 y = 1299989

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

q = 0 x1 = 179424710 x2 = 179424710 x = 179424711 q = 1 q = 0 x = 179424712 q = 1 q = 0 x = 179424713 q = 1 q = 0 x = 179424714 q = 1 q = 0 x = 179424715 q = 1 q = 0 x = 179424716 q = 1 q = 0 x = 179424717 q = 1 q = 0 x = 179424718 q = 1 q = 0 x = 179424719 y1 = 179424719 x1 = 179424709 q = 1 q = 0 x1 = 179424708 q = 1 q = 0 x1 = 179424707 q = 1 q = 0 x1 = 179424706 q = 1 q = 0 x1 = 179424705 q = 1 q = 0 x1 = 179424704 q = 1 q = 0 x1 = 179424703 q = 1 q = 0 x1 = 179424702 q = 1 q = 0 x1 = 179424701 q = 1 q = 0 x1 = 179424700 q = 1 q = 0 x1 = 179424699 q = 1 q = 0 x1 = 179424698 q = 1 q = 0 x1 = 179424697 y2 = 179424697 y = 179424719