Cody

# Problem 1722. Find the next prime number

Solution 1604717

Submitted on 9 Aug 2018 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
n = 1; out = 2; assert(isequal(nextprimenum(n),out))

y = [] t = 2 y = 2

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

y = [] t = 8 t = 9 t = 10 t = 11 y = 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))

y = [] t = 2 y = 2 t = 3 y = 2 3 t = 4 t = 5 y = 2 3 5 t = 5 y = 2 3 5 5 t = 6 t = 7 y = 2 3 5 5 7 t = 7 y = 2 3 5 5 7 7 t = 8 t = 9 t = 10 t = 11 y = 2 3 5 5 7 7 11 t = 9 t = 10 t = 11 y = 2 3 5 5 7 7 11 11 t = 10 t = 11 y = 2 3 5 5 7 7 11 11 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))

y = [] t = 72 t = 73 y = 73 t = 26 t = 27 t = 28 t = 29 y = 73 29 t = 64 t = 65 t = 66 t = 67 y = 73 29 67 t = 48 t = 49 t = 50 t = 51 t = 52 t = 53 y = 73 29 67 53 t = 66 t = 67 y = 73 29 67 53 67 t = 37 y = 73 29 67 53 67 37 t = 48 t = 49 t = 50 t = 51 t = 52 t = 53 y = 73 29 67 53 67 37 53 t = 59 y = 73 29 67 53 67 37 53 59 t = 70 t = 71 y = 73 29 67 53 67 37 53 59 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))

y = [] t = 172 t = 173 y = 173 t = 256 t = 257 y = 173 257 t = 637 t = 638 t = 639 t = 640 t = 641 y = 173 257 641 t = 488 t = 489 t = 490 t = 491 y = 173 257 641 491 t = 676 t = 677 y = 173 257 641 491 677 t = 370 t = 371 t = 372 t = 373 y = 173 257 641 491 677 373 t = 478 t = 479 y = 173 257 641 491 677 373 479 t = 539 t = 540 t = 541 y = 173 257 641 491 677 373 479 541 t = 970 t = 971 y = 173 257 641 491 677 373 479 541 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))

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