Cody

# Problem 60. The Goldbach Conjecture

Solution 399113

Submitted on 7 Feb 2014 by Yoshio
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 = 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 1 p1 = 5 p2 = 23 j = 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 1 p1 = 3 p2 = 31 j = 0 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 0 1 p1 = 3 p2 = 37 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 1 p1 = 3 p2 = 43 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 p1 = 5 p2 = 47 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 p1 = 5 p2 = 53 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 18 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 18 0 1 p1 = 3 p2 = 61 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 19 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 19 0 0 1 p1 = 3 p2 = 67 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 21 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 21 0 0 0 0 1 p1 = 3 p2 = 73

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 = 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 j = 0 0 0 0 0 1 0 p1 = 5 p2 = 13 j = 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 1 0 p1 = 3 p2 = 17 j = 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 1 p1 = 3 p2 = 19 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 25 0 0 0 0 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 25 0 0 0 0 0 0 0 0 1 p1 = 3 p2 = 97 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 26 0 0 0 0 0 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 26 0 0 0 0 0 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 26 0 0 0 0 0 0 0 0 1 0 p1 = 5 p2 = 97 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 30 0 0 0 0 0 0 0 0 0 0 0 0 1 0 p1 = 5 p2 = 109 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 65 through 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 81 through 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 97 through 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 113 through 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 129 through 144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 145 through 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 161 through 168 0 0 0 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 65 through 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 81 through 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 97 through 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 113 through 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 129 through 144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 145 through 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 161 through 168 0 0 0 0 0 0 0 1 p1 = 3 p2 = 997 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 65 through 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 81 through 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 97 through 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 113 through 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 129 through 144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 145 through 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 161 through 176 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 177 through 192 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 193 through 208 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 209 through 224 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 225 through 240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 241 through 256 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 257 through 272 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 273 through 288 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 289 through 303 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 65 through 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 81 through 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 97 through 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 113 through 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 129 through 144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 145 through 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 161 through 176 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 177 through 192 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 193 through 208 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 209 through 224 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 225 through 240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 241 through 256 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 257 through 272 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 273 through 288 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 289 through 303 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 p1 = 3 p2 = 1997 j = 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 0 j = 0 0 0 0 0 0 0 0 0 0 1 p1 = 5 p2 = 31 j = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...