Cody

Problem 1722. Find the next prime number

Solution 351315

Submitted on 14 Nov 2013 by Zikobrelli
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))

j = 1 y = 2

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

j = 1 j = 2 i = 1 j = 3 i = 1 j = 4 i = 1 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))

j = 1 y = 2 j = 1 y = 2 3 j = 1 j = 2 i = 3 y = 2 3 5 j = 1 y = 2 3 5 5 j = 1 j = 2 i = 5 y = 2 3 5 5 7 j = 1 y = 2 3 5 5 7 7 j = 1 j = 2 i = 7 j = 3 i = 7 j = 4 i = 7 y = 2 3 5 5 7 7 11 j = 1 j = 2 i = 8 j = 3 i = 8 y = 2 3 5 5 7 7 11 11 j = 1 j = 2 i = 9 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))

j = 1 j = 2 i = 1 y = 73 j = 1 j = 2 i = 2 j = 3 i = 2 j = 4 i = 2 y = 73 29 j = 1 j = 2 i = 3 j = 3 i = 3 j = 4 i = 3 y = 73 29 67 j = 1 j = 2 i = 4 j = 3 i = 4 j = 4 i = 4 j = 5 i = 4 j = 6 i = 4 y = 73 29 67 53 j = 1 j = 2 i = 5 y = 73 29 67 53 67 j = 1 y = 73 29 67 53 67 37 j = 1 j = 2 i = 7 j = 3 i = 7 j = 4 i = 7 j = 5 i = 7 j = 6 i = 7 y = 73 29 67 53 67 37 53 j = 1 y = 73 29 67 53 67 37 53 59 j = 1 j = 2 i = 9 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))

j = 1 j = 2 i = 1 y = 173 j = 1 j = 2 i = 2 y = 173 257 j = 1 j = 2 i = 3 j = 3 i = 3 j = 4 i = 3 j = 5 i = 3 y = 173 257 641 j = 1 j = 2 i = 4 j = 3 i = 4 j = 4 i = 4 y = 173 257 641 491 j = 1 j = 2 i = 5 y = 173 257 641 491 677 j = 1 j = 2 i = 6 j = 3 i = 6 j = 4 i = 6 y = 173 257 641 491 677 373 j = 1 j = 2 i = 7 y = 173 257 641 491 677 373 479 j = 1 j = 2 i = 8 j = 3 i = 8 y = 173 257 641 491 677 373 479 541 j = 1 j = 2 i = 9 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))

j = 1 j = 2 i = 1 j = 3 i = 1 j = 4 i = 1 j = 5 i = 1 j = 6 i = 1 j = 7 i = 1 j = 8 i = 1 j = 9 i = 1 j = 10 i = 1 j = 11 i = 1 j = 12 i = 1 y = 172553 j = 1 j = 2 i = 2 j = 3 i = 2 j = 4 i = 2 j = 5 i = 2 j = 6 i = 2 j = 7 i = 2 y = 172553 255571 j = 1 j = 2 i = 3 j = 3 i = 3 j = 4 i = 3 j = 5 i = 3 j = 6 i = 3 j = 7 i = 3 j = 8 i = 3 j = 9 i = 3 j = 10 i = 3 j = 11 i = 3 y = 172553 255571 632447 j = 1 j = 2 i = 4 y = 172553 255571 632447 4564589 j = 1 j = 2 i = 5 j = 3 i = 5 j = 4 i = 5 j = 5 i = 5 j = 6 i = 5 j = 7 i = 5 j = 8 i = 5 j = 9 i = 5 j = 10 i = 5 j = 11 i = 5 j = 12 i = 5 j = 13 i = 5 j = 14 i = 5 j = 15 i = 5 j = 16 i = 5 y = 172553 255571 632447 4564589 6778691 j = 1 j = 2 i = 6 j = 3 i = 6 j = 4 i = 6 j = 5 i = 6 j = 6 i = 6 j = 7 i = 6 j = 8 i = 6 j = 9 i = 6 j = 10 i = 6 j = 11 i = 6 j = 12 i = 6 j = 13 i = 6 j = 14 i = 6 j = 15 i = 6 j = 16 i = 6 j = 17 i = 6 j = 18 i = 6 y = 172553 255571 632447 4564589 6778691 334487 j = 1 j = 2 i = 7 y = 172553 255571 632447 4564589 6778691 334487 475649 j = 1 j = 2 i = 8 j = 3 i = 8 j = 4 i = 8 j = 5 i = 8 j = 6 i = 8 j = 7 i = 8 j = 8 i = 8 j = 9 i = 8 y = 172553 255571 632447 4564589 6778691 334487 475649 575647 j = 1 j = 2 i = 9 j = 3 i = 9 j = 4 i = 9 j = 5 i = 9 j = 6 i = 9 j = 7 i = 9 j = 8 i = 9 j = 9 i = 9 j = 10 i = 9 j = 11 i = 9 j = 12 i = 9 j = 13 i = 9 j = 14 i = 9 y = Columns 1 through 8 172553 255571 632447 4564589 6778691 334487 475649 575647 Column 9 96893