Cody

Problem 1722. Find the next prime number

Solution 2039656

Submitted on 30 Nov 2019 by Liam Storan
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))

l = 1 dummyboi = 0 z = 2 dummyboi = 2

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

l = 1 dummyboi = 0 z = 8 dummyboi = 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))

l = 9 dummyboi = 0 0 0 0 0 0 0 0 0 z = 2 dummyboi = 2 0 0 0 0 0 0 0 0 z = 3 dummyboi = 2 3 0 0 0 0 0 0 0 z = 4 dummyboi = 2 3 5 0 0 0 0 0 0 z = 5 dummyboi = 2 3 5 5 0 0 0 0 0 z = 6 dummyboi = 2 3 5 5 7 0 0 0 0 z = 7 dummyboi = 2 3 5 5 7 7 0 0 0 z = 8 dummyboi = 2 3 5 5 7 7 11 0 0 z = 9 dummyboi = 2 3 5 5 7 7 11 11 0 z = 10 dummyboi = 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))

l = 9 dummyboi = 0 0 0 0 0 0 0 0 0 z = 72 dummyboi = 73 0 0 0 0 0 0 0 0 z = 26 dummyboi = 73 29 0 0 0 0 0 0 0 z = 64 dummyboi = 73 29 67 0 0 0 0 0 0 z = 48 dummyboi = 73 29 67 53 0 0 0 0 0 z = 66 dummyboi = 73 29 67 53 67 0 0 0 0 z = 37 dummyboi = 73 29 67 53 67 37 0 0 0 z = 48 dummyboi = 73 29 67 53 67 37 53 0 0 z = 59 dummyboi = 73 29 67 53 67 37 53 59 0 z = 70 dummyboi = 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))

l = 9 dummyboi = 0 0 0 0 0 0 0 0 0 z = 172 dummyboi = 173 0 0 0 0 0 0 0 0 z = 256 dummyboi = 173 257 0 0 0 0 0 0 0 z = 637 dummyboi = 173 257 641 0 0 0 0 0 0 z = 488 dummyboi = 173 257 641 491 0 0 0 0 0 z = 676 dummyboi = 173 257 641 491 677 0 0 0 0 z = 370 dummyboi = 173 257 641 491 677 373 0 0 0 z = 478 dummyboi = 173 257 641 491 677 373 479 0 0 z = 539 dummyboi = 173 257 641 491 677 373 479 541 0 z = 970 dummyboi = 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))

l = 9 dummyboi = 0 0 0 0 0 0 0 0 0 z = 172542 dummyboi = 172553 0 0 0 0 0 0 0 0 z = 255565 dummyboi = 172553 255571 0 0 0 0 0 0 0 z = 632437 dummyboi = 172553 255571 632447 0 0 0 0 0 0 z = 4564588 dummyboi = 172553 255571 632447 4564589 0 0 0 0 0 z = 6778676 dummyboi = 172553 255571 632447 4564589 6778691 0 0 0 0 z = 334470 dummyboi = 172553 255571 632447 4564589 6778691 334487 0 0 0 z = 475648 dummyboi = 172553 255571 632447 4564589 6778691 334487 475649 0 0 z = 575639 dummyboi = 172553 255571 632447 4564589 6778691 334487 475649 575647 0 z = 96880 dummyboi = 172553 255571 632447 4564589 6778691 334487 475649 575647 96893

Suggested Problems

More from this Author17

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!