Cody

# Problem 60. The Goldbach Conjecture

Solution 1984926

Submitted on 21 Oct 2019 by Giorgia Campori
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

b = 5 23 b = 11 17 b = 17 11 b = 23 5 p1 = 23 p2 = 5 p1 = 23 p2 = 5 b = 3 31 b = 5 29 b = 11 23 b = 17 17 b = 23 11 b = 29 5 b = 31 3 p1 = 31 p2 = 3 p1 = 31 p2 = 3 b = 3 37 b = 11 29 b = 17 23 b = 23 17 b = 29 11 b = 37 3 p1 = 37 p2 = 3 p1 = 37 p2 = 3 b = 3 43 b = 5 41 b = 17 29 b = 23 23 b = 29 17 b = 41 5 b = 43 3 p1 = 43 p2 = 3 p1 = 43 p2 = 3 b = 5 47 b = 11 41 b = 23 29 b = 29 23 b = 41 11 b = 47 5 p1 = 47 p2 = 5 p1 = 47 p2 = 5 b = 5 53 b = 11 47 b = 17 41 b = 29 29 b = 41 17 b = 47 11 b = 53 5 p1 = 53 p2 = 5 p1 = 53 p2 = 5 b = 3 61 b = 5 59 b = 11 53 b = 17 47 b = 23 41 b = 41 23 b = 47 17 b = 53 11 b = 59 5 b = 61 3 p1 = 61 p2 = 3 p1 = 61 p2 = 3 b = 3 67 b = 11 59 b = 17 53 b = 23 47 b = 29 41 b = 41 29 b = 47 23 b = 53 17 b = 59 11 b = 67 3 p1 = 67 p2 = 3 p1 = 67 p2 = 3 b = 3 73 b = 5 71 b = 17 59 b = 23 53 b = 29 47 b = 47 29 b = 53 23 b = 59 17 b = 71 5 b = 73 3 p1 = 73 p2 = 3 p1 = 73 p2 = 3

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

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