Cody

Solution 1970278

Submitted on 10 Oct 2019 by Julian Lippmann
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))

low = -1 high = 0 high_closer = logical 1 high = 1 high = 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))

low = 99 low = 98 low = 97 high = 100 high_closer = logical 1 high = 101 y = 101

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

low = 499 high = 500 high_closer = logical 1 high = 501 high = 502 high_closer = logical 0 high = 503 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))

low = 2499 low = 2498 low = 2497 low = 2496 low = 2495 low = 2494 low = 2493 low = 2492 low = 2491 low = 2490 low = 2489 low = 2488 low = 2487 low = 2486 low = 2485 low = 2484 low = 2483 low = 2482 low = 2481 low = 2480 low = 2479 low = 2478 low = 2477 high = 2500 high_closer = logical 1 high = 2501 high = 2502 high = 2503 y = 2503

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

low = 7999 low = 7998 low = 7997 low = 7996 low = 7995 low = 7994 low = 7993 high = 8000 high_closer = logical 1 high = 8001 high = 8002 high = 8003 high = 8004 high = 8005 high = 8006 high = 8007 high = 8008 high_closer = logical 0 high = 8009 y = 7993

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

low = 99999 low = 99998 low = 99997 low = 99996 low = 99995 low = 99994 low = 99993 low = 99992 low = 99991 high = 100000 high_closer = logical 1 high = 100001 high = 100002 high = 100003 y = 100003

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

low = 1299999 low = 1299998 low = 1299997 low = 1299996 low = 1299995 low = 1299994 low = 1299993 low = 1299992 low = 1299991 low = 1299990 low = 1299989 high = 1300000 high_closer = logical 1 high = 1300001 high = 1300002 high = 1300003 high = 1300004 high = 1300005 high = 1300006 high = 1300007 high = 1300008 high = 1300009 high = 1300010 high = 1300011 high = 1300012 high_closer = logical 0 high = 1300013 y = 1299989

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

low = 179424709 low = 179424708 low = 179424707 low = 179424706 low = 179424705 low = 179424704 low = 179424703 low = 179424702 low = 179424701 low = 179424700 low = 179424699 low = 179424698 low = 179424697 high = 179424710 high_closer = logical 1 high = 179424711 high = 179424712 high = 179424713 high = 179424714 high = 179424715 high = 179424716 high = 179424717 high = 179424718 high = 179424719 y = 179424719