Cody

# Problem 60. The Goldbach Conjecture

Solution 856643

Submitted on 25 Mar 2016 by Trung Duong
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

i2 = Columns 1 through 16 0 1 1 0 2 0 1 0 1 0 2 0 1 0 1 0 Columns 17 through 27 2 0 1 0 1 0 2 0 1 1 0 p1 = 5 p2 = 23 i2 = Columns 1 through 16 0 1 2 0 2 0 1 0 0 0 2 0 1 0 1 0 Columns 17 through 32 2 0 1 0 1 0 2 0 0 0 1 0 2 0 2 1 Column 33 0 p1 = 3 p2 = 31 i2 = Columns 1 through 16 0 1 2 0 1 0 1 0 1 0 2 0 1 0 0 0 Columns 17 through 32 2 0 1 0 1 0 2 0 0 0 1 0 2 0 1 0 Columns 33 through 39 1 0 1 0 2 1 0 p1 = 3 p2 = 37 i2 = Columns 1 through 16 0 1 2 0 2 0 1 0 1 0 1 0 1 0 1 0 Columns 17 through 32 2 0 1 0 0 0 2 0 0 0 1 0 2 0 1 0 Columns 33 through 45 1 0 1 0 1 0 1 0 2 0 2 1 0 p1 = 3 p2 = 43 i2 = Columns 1 through 16 0 1 1 0 2 0 1 0 1 0 2 0 1 0 1 0 Columns 17 through 32 1 0 1 0 1 0 2 0 0 0 0 0 2 0 1 0 Columns 33 through 48 1 0 1 0 1 0 1 0 2 0 1 0 1 0 2 0 Columns 49 through 51 1 1 0 p1 = 5 p2 = 47 i2 = Columns 1 through 16 0 1 1 0 2 0 1 0 0 0 2 0 1 0 1 0 Columns 17 through 32 2 0 1 0 1 0 1 0 0 0 1 0 2 0 1 0 Columns 33 through 48 0 0 1 0 1 0 1 0 2 0 1 0 1 0 2 0 Columns 49 through 57 0 0 1 0 2 0 1 1 0 p1 = 5 p2 = 53 i2 = Columns 1 through 16 0 1 2 0 2 0 1 0 0 0 2 0 1 0 0 0 Columns 17 through 32 2 0 1 0 1 0 2 0 0 0 1 0 1 0 1 0 Columns 33 through 48 1 0 1 0 1 0 0 0 2 0 1 0 1 0 2 0 Columns 49 through 63 0 0 1 0 2 0 0 0 1 0 2 0 2 1 0 p1 = 3 p2 = 61 i2 = Columns 1 through 16 0 1 2 0 1 0 1 0 1 0 2 0 1 0 0 0 Columns 17 through 32 2 0 1 0 0 0 2 0 0 0 1 0 2 0 1 0 Columns 33 through 48 1 0 0 0 1 0 1 0 2 0 1 0 0 0 2 0 Columns 49 through 64 0 0 1 0 2 0 0 0 1 0 2 0 1 0 1 0 Columns 65 through 69 1 0 2 1 0 p1 = 3 p2 = 67 i2 = Columns 1 through 16 0 1 2 0 2 0 1 0 1 0 1 0 1 0 1 0 Columns 17 through 32 2 0 1 0 0 0 2 0 0 0 0 0 2 0 1 0 Columns 33 through 48 1 0 1 0 1 0 1 0 1 0 1 0 1 0 2 0 Columns 49 through 64 0 0 0 0 2 0 0 0 1 0 2 0 1 0 1 0 Columns 65 through 75 1 0 1 0 1 0 2 0 2 1 0 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

i2 = Columns 1 through 16 1 1 1 0 2 0 2 0 0 0 2 0 2 0 1 1 Column 17 1 p1 = 5 p2 = 13 i2 = Columns 1 through 16 1 1 2 0 1 0 2 0 1 0 1 0 2 0 1 0 Columns 17 through 19 2 1 1 p1 = 3 p2 = 17 i2 = Columns 1 through 16 0 1 2 0 2 0 1 0 1 0 2 0 1 0 1 0 Columns 17 through 21 2 0 2 1 0 p1 = 3 p2 = 19 i2 = Columns 1 through 16 0 1 2 0 1 0 1 0 0 0 2 0 1 0 0 0 Columns 17 through 32 2 0 1 0 1 0 1 0 0 0 1 0 2 0 1 0 Columns 33 through 48 1 0 0 0 1 0 1 0 2 0 1 0 0 0 2 0 Columns 49 through 64 0 0 0 0 2 0 0 0 1 0 2 0 1 0 1 0 Columns 65 through 80 0 0 1 0 1 0 2 0 1 0 0 0 1 0 1 0 Columns 81 through 96 1 0 2 0 0 0 1 0 2 0 0 0 1 0 1 0 Columns 97 through 99 2 1 0 p1 = 3 p2 = 97 i2 = Columns 1 through 16 1 1 1 0 2 0 1 0 0 0 1 0 2 0 0 0 Columns 17 through 32 1 0 2 0 0 0 2 0 0 0 0 0 2 0 2 0 Columns 33 through 48 0 0 1 0 1 0 0 0 2 0 2 0 0 0 1 0 Columns 49 through 64 1 0 0 0 1 0 1 0 0 0 2 0 2 0 0 0 Columns 65 through 80 1 0 1 0 0 0 2 0 2 0 0 0 0 0 2 0 Columns 81 through 96 0 0 2 0 1 0 0 0 2 0 1 0 0 0 1 0 Columns 97 through 101 2 0 1 1 1 p1 = 5 p2 = 97 i2 = Columns 1 through 16 1 1 1 0 2 0 2 0 0 0 2 0 2 0 0 0 Columns 17 through 32 2 0 1 0 0 0 1 0 1 0 0 0 1 0 2 0 Columns 33 through 48 0 0 1 0 1 0 0 0 2 0 2 0 0 0 2 0 Columns 49 through 64 0 0 0 0 2 0 1 0 0 0 1 0 2 0 0 0 Columns 65 through 80 0 0 2 0 0 0 2 0 2 0 0 0 1 0 1 0 Columns 81 through 96 0 0 2 0 1 0 0 0 1 0 1 0 0 0 1 0 Columns 97 through 112 2 0 0 0 2 0 2 0 0 0 2 0 2 0 1 1 Column 113 1 p1 = 5 p2 = 109 i2 = Columns 1 through 16 0 1 2 0 1 0 1 0 1 0 1 0 1 0 0 0 Columns 17 through 32 2 0 1 0 0 0 2 0 0 0 0 0 2 0 1 0 Columns 33 through 48 1 0 0 0 1 0 0 0 1 0 1 0 0 0 2 0 Columns 49 through 64 0 0 0 0 2 0 0 0 0 0 2 0 1 0 1 0 Columns 65 through 80 0 0 1 0 0 0 2 0 1 0 0 0 0 0 1 0 Columns 81 through 96 1 0 1 0 0 0 0 0 2 0 0 0 1 0 0 0 Columns 97 through 112 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 Columns 113 through 128 2 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 Columns 129 through 144 0 0 1 0 0 0 0 0 2 0 1 0 1 0 1 0 Columns 145 through 160 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 Columns 161 through 176 1 0 1 0 0 0 1 0 0 0 1 0 2 0 0 0 Columns 177 through 192 1 0 2 0 1 0 0 0 0 0 0 0 1 0 2 0 Columns 193 through 208 1 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 Columns 209 through 224 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 Columns 225 through 240 0 0 2 0 1 0 1 0 1 0 0 0 0 0 2 0 Columns 241 through 256 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 Columns 257 through 272 2 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 Columns 273 through 288 1 0 0 0 1 0 0 0 2 0 1 0 0 0 0 0 Columns 289 through 304 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 Columns 305 through 320 0 0 1 0 1 0 1 0 1 0 0 0 2 0 0 0 Columns 321 through 336 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 Columns 337 through 352 1 0 1 0 1 0 0 0 0 0 2 0 1 0 0 0 Columns 353 through 368 2 0 0 0 1 0 2 0 0 0 0 0 0 0 1 0 Columns 369 through 384 1 0 0 0 1 0 0 0 0 0 1 0 1 0 2 0 Columns 385 through 400 0 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 Columns 401 through 416 2 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 Columns 417 through 432 0 0 1 0 1 0 1 0 0 0 0 0 1 0 2 0 Columns 433 through 448 1 0 0 0 1 0 1 0 0 0 2 0 0 0 0 0 Columns 449 through 464 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 Columns 465 through 480 0 0 1 0 0 0 0 0 0 0 0 0 1 0 2 0 Columns 481 through 496 0 0 0 0 0 0 1 0 0 0 2 0 0 0 0 0 Columns 497 through 512 1 0 1 0 1 0 1 0 0 0 0 0 2 0 0 0 Columns 513 through 528 1 0 0 0 0 0 0 0 2 0 1 0 0 0 0 0 Columns 529 through 544 0 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 Columns 545 through 560 0 0 1 0 0 0 1 0 0 0 0 0 2 0 0 0 Columns 561 through 576 1 0 1 0 0 0 1 0 2 0 1 0 0 0 0 0 Columns 577 through 592 1 0 1 0 1 0 0 0 0 0 1 0 0 0 1 0 Columns 593 through 608 1 0 0 0 0 0 2 0 1 0 1 0 0 0 1 0 Columns 609 through 624 0 0 1 0 1 0 0 0 2 0 1 0 1 0 0 0 Columns 625 through 640 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 Columns 641 through 656 2 0 1 0 0 0 2 0 0 0 1 0 2 0 0 0 Columns 657 through 672 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 Columns 673 through 688 1 0 0 0 1 0 0 0 0 0 2 0 0 0 1 0 Columns 689 through 704 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 Columns 705 through 720 0 0 1 0 1 0 0 0 0 0 0 0 1 0 2 0 Columns 721 through 736 0 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 Columns 737 through 752 1 0 1 0 0 0 2 0 0 0 0 0 1 0 1 0 Columns 753 through 768 0 0 0 0 1 0 1 0 2 0 0 0 0 0 1 0 Columns 769 through 784 1 0 1 0 2 0 0 0 1 0 0 0 0 0 0 0 Columns 785 through 800 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 Columns 801 through 816 1 0 1 0 0 0 1 0 2 0 1 0 0 0 0 0 Columns 817 through 832 0 0 1 0 2 0 1 0 0 0 2 0 1 0 0 0 Columns 833 through 848 1 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 Columns 849 through 864 1 0 1 0 1 0 0 0 1 0 1 0 1 0 2 0 Columns 865 through 880 0 0 0 0 1 0 0 0 1 0...