Cody

# Problem 60. The Goldbach Conjecture

Solution 1319109

Submitted on 29 Oct 2017 by Leo Nunnink
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

j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 j = 11 l = 13 l = 17 j = 13 l = 17 l = 19 l = 23 j = 17 l = 19 l = 23 j = 19 l = 23 j = 23 p1 = 11 p2 = 17 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 j = 11 l = 13 l = 17 l = 19 l = 23 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 j = 17 l = 19 l = 23 l = 29 l = 31 j = 19 l = 23 l = 29 l = 31 j = 23 l = 29 l = 31 j = 29 l = 31 j = 31 p1 = 11 p2 = 23 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 j = 11 l = 13 l = 17 l = 19 l = 23 l = 29 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 j = 17 l = 19 l = 23 j = 19 l = 23 l = 29 l = 31 l = 37 j = 23 l = 29 l = 31 l = 37 j = 29 l = 31 l = 37 j = 31 l = 37 j = 37 p1 = 17 p2 = 23 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 j = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 j = 17 l = 19 l = 23 l = 29 j = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 j = 23 l = 29 l = 31 l = 37 l = 41 l = 43 j = 29 l = 31 l = 37 l = 41 l = 43 j = 31 l = 37 l = 41 l = 43 j = 37 l = 41 l = 43 j = 41 l = 43 j = 43 p1 = 17 p2 = 29 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 23 l = 29 j = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 31 l = 37 l = 41 l = 43 l = 47 j = 37 l = 41 l = 43 l = 47 j = 41 l = 43 l = 47 j = 43 l = 47 j = 47 p1 = 23 p2 = 29 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 j = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 37 l = 41 l = 43 l = 47 l = 53 j = 41 l = 43 l = 47 l = 53 j = 43 l = 47 l = 53 j = 47 l = 53 j = 53 p1 = 17 p2 = 41 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 j = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 23 l = 29 l = 31 l = 37 l = 41 j = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 43 l = 47 l = 53 l = 59 l = 61 j = 47 l = 53 l = 59 l = 61 j = 53 l = 59 l = 61 j = 59 l = 61 j = 61 p1 = 23 p2 = 41 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = ...

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

j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 j = 5 l = 7 l = 11 l = 13 j = 7 l = 11 j = 11 l = 13 l = 17 j = 13 l = 17 j = 17 p1 = 7 p2 = 11 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 j = 7 l = 11 l = 13 j = 11 l = 13 l = 17 l = 19 j = 13 l = 17 l = 19 j = 17 l = 19 j = 19 p1 = 7 p2 = 13 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 j = 5 l = 7 l = 11 l = 13 l = 17 j = 7 l = 11 l = 13 l = 17 l = 19 j = 11 l = 13 l = 17 l = 19 j = 13 l = 17 l = 19 j = 17 l = 19 j = 19 p1 = 5 p2 = 17 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 j = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 j = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 41 l = 43 l = 47 l = 53 l = 59 j = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 47 l = 53 j = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 73 l = 79 l = 83 l = 89 l = 97 j = 79 l = 83 l = 89 l = 97 j = 83 l = 89 l = 97 j = 89 l = 97 j = 97 p1 = 47 p2 = 53 j = 2 l = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 3 l = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 5 l = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 j = 7 l = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 11 l = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 13 l = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 j = 17 l = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 19 l = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 j = 23 l = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 j = 29 l = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 j = 31 l = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 j = 37 l = 41 l = 43 l = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 41 l = 43 l = 47 l = 53 l = 59 l = 61 j = 43 l = 47 l = 53 l = 59 j = 47 l = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 53 l = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 59 l = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 61 l = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 67 l = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 71 l = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 73 l = 79 l = 83 l = 89 l = 97 l = 101 j = 79 l = 83 l = 89 l = 97 l = 101 j = 83 l = 89 l = 97 l = 101 j = 89 l = 97 l = 101 j = 97 l = 101 j = 10...