Cody

Solution 1977611

Submitted on 15 Oct 2019 by Joseph Chambers
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
nList = 28:6:76; for i = 1:length(nList) n = nList(i); [p1,p2] = goldbach(n) assert(isprime(p1) && isprime(p2) && (p1+p2==n)); end

nums = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 primes = 2 3 5 7 11 13 17 19 23 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 p1 = 5 p2 = 23 j = 10 i = 4 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 i = 5 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 p1 = 11 p2 = 17 j = 8 j = 9 j = 10 i = 6 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 i = 7 j = 2 j = 3 j = 4 j = 5 p1 = 17 p2 = 11 j = 6 j = 7 j = 8 j = 9 j = 10 i = 8 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 i = 9 j = 2 j = 3 p1 = 23 p2 = 5 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 i = 10 p1 = 23 p2 = 5 nums = Columns 1 through 30 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 31 through 33 32 33 34 primes = 2 3 5 7 11 13 17 19 23 29 31 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 p1 = 3 p2 = 31 j = 12 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 p1 = 5 p2 = 29 j = 11 j = 12 i = 4 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 i = 5 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 p1 = 11 p2 = 23 j = 10 j = 11 j = 12 i = 6 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 i = 7 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 p1 = 17 p2 = 17 j = 8 j = 9 j = 10 j = 11 j = 12 i = 8 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 i = 9 j = 2 j = 3 j = 4 j = 5 p1 = 23 p2 = 11 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 i = 10 j = 2 j = 3 p1 = 29 p2 = 5 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 i = 11 j = 2 p1 = 31 p2 = 3 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 i = 12 p1 = 31 p2 = 3 nums = Columns 1 through 30 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 31 through 39 32 33 34 35 36 37 38 39 40 primes = 2 3 5 7 11 13 17 19 23 29 31 37 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 p1 = 3 p2 = 37 j = 13 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 4 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 5 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 p1 = 11 p2 = 29 j = 11 j = 12 j = 13 i = 6 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 7 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 p1 = 17 p2 = 23 j = 10 j = 11 j = 12 j = 13 i = 8 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 9 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 p1 = 23 p2 = 17 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 10 j = 2 j = 3 j = 4 j = 5 p1 = 29 p2 = 11 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 11 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 12 j = 2 p1 = 37 p2 = 3 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 i = 13 p1 = 37 p2 = 3 nums = Columns 1 through 30 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 31 through 45 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 primes = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 p1 = 3 p2 = 43 j = 15 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 p1 = 5 p2 = 41 j = 14 j = 15 i = 4 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 5 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 6 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 7 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 p1 = 17 p2 = 29 j = 11 j = 12 j = 13 j = 14 j = 15 i = 8 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 9 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 p1 = 23 p2 = 23 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 10 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 p1 = 29 p2 = 17 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 11 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 i = 12 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 ...

2   Pass
nList = [18 20 22 100 102 114 1000 2000 36 3600]; for i = 1:length(nList) n = nList(i); [p1,p2] = goldbach(n) assert(isprime(p1) && isprime(p2) && (p1+p2==n)); end

nums = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 primes = 2 3 5 7 11 13 17 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 p1 = 5 p2 = 13 j = 7 j = 8 i = 4 j = 2 j = 3 j = 4 j = 5 p1 = 7 p2 = 11 j = 6 j = 7 j = 8 i = 5 j = 2 j = 3 j = 4 p1 = 11 p2 = 7 j = 5 j = 6 j = 7 j = 8 i = 6 j = 2 j = 3 p1 = 13 p2 = 5 j = 4 j = 5 j = 6 j = 7 j = 8 i = 7 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 i = 8 p1 = 13 p2 = 5 nums = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 primes = 2 3 5 7 11 13 17 19 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 p1 = 3 p2 = 17 j = 8 j = 9 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 4 j = 2 j = 3 j = 4 j = 5 j = 6 p1 = 7 p2 = 13 j = 7 j = 8 j = 9 i = 5 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 6 j = 2 j = 3 j = 4 p1 = 13 p2 = 7 j = 5 j = 6 j = 7 j = 8 j = 9 i = 7 j = 2 p1 = 17 p2 = 3 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 8 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 9 p1 = 17 p2 = 3 nums = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 primes = 2 3 5 7 11 13 17 19 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 p1 = 3 p2 = 19 j = 9 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 p1 = 5 p2 = 17 j = 8 j = 9 i = 4 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 5 j = 2 j = 3 j = 4 j = 5 p1 = 11 p2 = 11 j = 6 j = 7 j = 8 j = 9 i = 6 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 7 j = 2 j = 3 p1 = 17 p2 = 5 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 8 j = 2 p1 = 19 p2 = 3 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 i = 9 p1 = 19 p2 = 3 nums = Columns 1 through 30 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Columns 31 through 60 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 Columns 61 through 90 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 Columns 91 through 99 92 93 94 95 96 97 98 99 100 primes = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 p1 = 1 p2 = 1 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 2 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 p1 = 3 p2 = 97 j = 26 i = 3 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 4 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 5 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 p1 = 11 p2 = 89 j = 25 j = 26 i = 6 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 7 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 p1 = 17 p2 = 83 j = 24 j = 25 j = 26 i = 8 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 9 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 10 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 p1 = 29 p2 = 71 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 11 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 12 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 13 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 p1 = 41 p2 = 59 j = 18 j = 19 j = 20 j = 21 j = 22 j = 23 j = 24 j = 25 j = 26 i = 14 j = 2 j = 3 j = 4 j = 5 j = 6 j = 7 j = 8 j = 9 j = 10 j = 11 j = 12 j = 13 j = 14 j = 15 j = 16 j = 17 j = 18 j = 19 j = 20 j = 21 j = 22 ...