Cody

# Problem 60. The Goldbach Conjecture

Solution 502134

Submitted on 16 Sep 2014 by Kai
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

m = 5 11 17 23 p1 = 5 p2 = 23 m = 3 5 11 17 23 29 31 p1 = 3 p2 = 31 m = 3 11 17 23 29 37 p1 = 3 p2 = 37 m = 3 5 17 23 29 41 43 p1 = 3 p2 = 43 m = 5 11 23 29 41 47 p1 = 5 p2 = 47 m = 5 11 17 29 41 47 53 p1 = 5 p2 = 53 m = 3 5 11 17 23 41 47 53 59 61 p1 = 3 p2 = 61 m = 3 11 17 23 29 41 47 53 59 67 p1 = 3 p2 = 67 m = 3 5 17 23 29 47 53 59 71 73 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

m = 5 7 11 13 p1 = 5 p2 = 13 m = 3 7 13 17 p1 = 3 p2 = 17 m = 3 5 11 17 19 p1 = 3 p2 = 19 m = 3 11 17 29 41 47 53 59 71 83 89 97 p1 = 3 p2 = 97 m = 5 13 19 23 29 31 41 43 59 61 71 73 79 83 89 97 p1 = 5 p2 = 97 m = Columns 1 through 16 5 7 11 13 17 31 41 43 47 53 61 67 71 73 83 97 Columns 17 through 20 101 103 107 109 p1 = 5 p2 = 109 m = Columns 1 through 16 3 17 23 29 47 53 59 71 89 113 137 173 179 191 227 239 Columns 17 through 32 257 281 317 347 353 359 383 401 431 443 479 491 509 521 557 569 Columns 33 through 48 599 617 641 647 653 683 719 743 761 773 809 821 827 863 887 911 Columns 49 through 56 929 941 947 953 971 977 983 997 p1 = 3 p2 = 997 m = Columns 1 through 8 3 7 13 67 127 139 199 211 Columns 9 through 16 223 241 277 307 331 337 373 379 Columns 17 through 24 421 433 457 541 547 571 577 601 Columns 25 through 32 619 673 709 751 769 787 829 877 Columns 33 through 40 883 907 937 967 991 1009 1033 1063 Columns 41 through 48 1093 1117 1123 1171 1213 1231 1249 1291 Columns 49 through 56 1327 1381 1399 1423 1429 1453 1459 1543 Columns 57 through 64 1567 1579 1621 1627 1663 1669 1693 1723 Columns 65 through 72 1759 1777 1789 1801 1861 1873 1933 1987 Columns 73 through 74 1993 1997 p1 = 3 p2 = 1997 m = 5 7 13 17 19 23 29 31 p1 = 5 p2 = 31 m = Columns 1 through 8 7 17 19 29 41 43 53 59 Columns 9 through 16 61 67 71 73 83 89 101 109 Columns 17 through 24 131 137 139 151 167 193 211 227 Columns 25 through 32 229 239 241 257 269 271 277 281 Columns 33 through 40 293 347 349 379 383 397 409 419 Columns 41 through 48 431 433 463 479 491 521 563 577 Columns 49 through 56 599 601 631 643 647 661 673 683 Columns 57 through 64 691 739 743 757 797 809 811 823 Columns 65 through 72 859 881 887 907 911 929 937 941 Columns 73 through 80 953 967 983 991 1009 1021 1049 1051 Columns 81 through 88 1061 1069 1097 1123 1153 1163 1201 1217 Columns 89 through 96 1223 1229 1249 1259 1289 1291 1303 1307 Columns 97 through 104 1319 1327 1361 1439 1447 1459 1471 1487 Columns 105 through 112 1489 1511 1531 1571 1583 1597 1601 1607 Columns 113 through 120 1613 1621 1627 1667 1669 1693 1699 1721 Columns 121 through 128 1723 1733 1753 1777 1789 1811 1823 1847 Columns 129 through 136 1867 1877 1879 1901 1907 1931 1933 1973 Columns 137 through 144 1979 1987 1993 1999 2003 2017 2029 2069 Columns 145 through 152 2089 2111 2113 2129 2141 2153 2161 2239 Columns 153 through 160 2273 2281 2293 2297 2309 2311 2341 2351 Columns 161 through 168 2371 2377 2383 2399 2437 2447 2477 2503 Columns 169 through 176 2531 2539 2549 2551 2579 2591 2609 2617 Columns 177 through 184 2633 2647 2659 2663 2671 2689 2693 2713 Columns 185 through 192 2719 2741 2777 2789 2791 2803 2843 2857 Columns 193 through 200 2861 2909 2917 2927 2939 2953 2957 2969 Columns 201 through 208 2999 3001 3023 3037 3079 3109 3121 3137 Columns 209 through 216 3167 3169 3181 3191 3203 3217 3221 3251 Columns 217 through 224 3253 3307 3319 3323 3329 3331 3343 3359 Columns 225 through 232 3361 3371 3373 3389 3407 3433 3449 3461 Columns 233 through 240 3463 3469 3491 3499 3511 3517 3527 3529 Columns 241 through 248 3533 3539 3541 3547 3557 3559 3571 3581 Columns 249 through 250 3583 3593 p1 = 7 p2 = 3593