Cody

# Problem 60. The Goldbach Conjecture

Solution 55263

Submitted on 2 Mar 2012 by James
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

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

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!