Cody

# Problem 1722. Find the next prime number

Solution 1799915

Submitted on 29 Apr 2019 by Margaret Hoeller
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 = 1; out = 2; assert(isequal(nextprimenum(n),out))

test = 2

2   Pass
n = 7; out = 11; assert(isequal(nextprimenum(n),out))

test = 8 test = 9 test = 10 test = 11

3   Pass
n = [1 2 3 4 5 6 7 8 9]; out = [2 3 5 5 7 7 11 11 11]; assert(isequal(nextprimenum(n),out))

test = 2 test = 3 test = 4 test = 5 test = 5 test = 6 test = 7 test = 7 test = 8 test = 9 test = 10 test = 11 test = 9 test = 10 test = 11 test = 10 test = 11

4   Pass
n = [71 25 63 47 65 36 47 58 69]; out = [73 29 67 53 67 37 53 59 71]; assert(isequal(nextprimenum(n),out))

test = 72 test = 73 test = 26 test = 27 test = 28 test = 29 test = 64 test = 65 test = 66 test = 67 test = 48 test = 49 test = 50 test = 51 test = 52 test = 53 test = 66 test = 67 test = 37 test = 48 test = 49 test = 50 test = 51 test = 52 test = 53 test = 59 test = 70 test = 71

5   Pass
n = [171 255 636 487 675 369 477 538 969]; out = [173 257 641 491 677 373 479 541 971]; assert(isequal(nextprimenum(n),out))

test = 172 test = 173 test = 256 test = 257 test = 637 test = 638 test = 639 test = 640 test = 641 test = 488 test = 489 test = 490 test = 491 test = 676 test = 677 test = 370 test = 371 test = 372 test = 373 test = 478 test = 479 test = 539 test = 540 test = 541 test = 970 test = 971

6   Pass
n = [172541 255564 632436 4564587 6778675 334469 475647 575638 96879]; out = [172553 255571 632447 4564589 6778691 334487 475649 575647 96893]; assert(isequal(nextprimenum(n),out))

test = 172542 test = 172543 test = 172544 test = 172545 test = 172546 test = 172547 test = 172548 test = 172549 test = 172550 test = 172551 test = 172552 test = 172553 test = 255565 test = 255566 test = 255567 test = 255568 test = 255569 test = 255570 test = 255571 test = 632437 test = 632438 test = 632439 test = 632440 test = 632441 test = 632442 test = 632443 test = 632444 test = 632445 test = 632446 test = 632447 test = 4564588 test = 4564589 test = 6778676 test = 6778677 test = 6778678 test = 6778679 test = 6778680 test = 6778681 test = 6778682 test = 6778683 test = 6778684 test = 6778685 test = 6778686 test = 6778687 test = 6778688 test = 6778689 test = 6778690 test = 6778691 test = 334470 test = 334471 test = 334472 test = 334473 test = 334474 test = 334475 test = 334476 test = 334477 test = 334478 test = 334479 test = 334480 test = 334481 test = 334482 test = 334483 test = 334484 test = 334485 test = 334486 test = 334487 test = 475648 test = 475649 test = 575639 test = 575640 test = 575641 test = 575642 test = 575643 test = 575644 test = 575645 test = 575646 test = 575647 test = 96880 test = 96881 test = 96882 test = 96883 test = 96884 test = 96885 test = 96886 test = 96887 test = 96888 test = 96889 test = 96890 test = 96891 test = 96892 test = 96893