Cody

# Problem 60. The Goldbach Conjecture

Solution 540217

Submitted on 4 Dec 2014 by Thomas
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

p = 26 B = 0 p = 25 B = 0 p = 23 B = 1 p = 21 B = 0 p = 17 B = 1 p = 15 B = 0 p = 11 B = 1 p = 9 B = 0 p = 5 B = 1 p1 = 23 p2 = 5 p = 32 B = 0 p = 31 B = 1 p = 29 B = 1 p = 27 B = 0 p = 23 B = 1 p = 21 B = 0 p = 17 B = 1 p = 15 B = 0 p = 11 B = 1 p = 5 B = 1 p = 3 B = 1 p1 = 31 p2 = 3 p = 38 B = 0 p = 37 B = 1 p = 35 B = 0 p = 33 B = 0 p = 29 B = 1 p = 27 B = 0 p = 23 B = 1 p = 21 B = 0 p = 17 B = 1 p = 11 B = 1 p = 9 B = 0 p = 3 B = 1 p1 = 37 p2 = 3 p = 44 B = 0 p = 43 B = 1 p = 41 B = 1 p = 39 B = 0 p = 35 B = 0 p = 33 B = 0 p = 29 B = 1 p = 27 B = 0 p = 23 B = 1 p = 17 B = 1 p = 15 B = 0 p = 9 B = 0 p = 5 B = 1 p = 3 B = 1 p1 = 43 p2 = 3 p = 50 B = 0 p = 49 B = 0 p = 47 B = 1 p = 45 B = 0 p = 41 B = 1 p = 39 B = 0 p = 35 B = 0 p = 33 B = 0 p = 29 B = 1 p = 23 B = 1 p = 21 B = 0 p = 15 B = 0 p = 11 B = 1 p = 9 B = 0 p = 5 B = 1 p1 = 47 p2 = 5 p = 56 B = 0 p = 55 B = 0 p = 53 B = 1 p = 51 B = 0 p = 47 B = 1 p = 45 B = 0 p = 41 B = 1 p = 39 B = 0 p = 35 B = 0 p = 29 B = 1 p = 27 B = 0 p = 21 B = 0 p = 17 B = 1 p = 15 B = 0 p = 11 B = 1 p = 5 B = 1 p1 = 53 p2 = 5 p = 62 B = 0 p = 61 B = 1 p = 59 B = 1 p = 57 B = 0 p = 53 B = 1 p = 51 B = 0 p = 47 B = 1 p = 45 B = 0 p = 41 B = 1 p = 35 B = 0 p = 33 B = 0 p = 27 B = 0 p = 23 B = 1 p = 21 B = 0 p = 17 B = 1 p = 11 B = 1 p = 5 B = 1 p = 3 B = 1 p1 = 61 p2 = 3 p = 68 B = 0 p = 67 B = 1 p = 65 B = 0 p = 63 B = 0 p = 59 B = 1 p = 57 B = 0 p = 53 B = 1 p = 51 B = 0 p = 47 B = 1 p = 41 B = 1 p = 39 B = 0 p = 33 B = 0 p = 29 B = 1 p = 27 B = 0 p = 23 B = 1 p = 17 B = 1 p = 11 B = 1 p = 9 B = 0 p = 3 B = 1 p1 = 67 p2 = 3 p = 74 B = 0 p = 73 B = 1 p = 71 B = 1 p = 69 B = 0 p = 65 B = 0 p = 63 B = 0 p = 59 B = 1 p = 57 B = 0 p = 53 B = 1 p = 47 B = 1 p = 45 B = 0 p = 39 B = 0 p = 35 B = 0 p = 33 B = 0 p = 29 B = 1 p = 23 B = 1 p = 17 B = 1 p = 15 B = 0 p = 9 B = 0 p = 5 B = 1 p = 3 B = 1 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

p = 16 B = 0 p = 15 B = 0 p = 13 B = 1 p = 11 B = 1 p = 7 B = 1 p = 5 B = 1 p = 1 B = 0 p1 = 13 p2 = 5 p = 18 B = 0 p = 17 B = 1 p = 15 B = 0 p = 13 B = 1 p = 9 B = 0 p = 7 B = 1 p = 3 B = 1 p = 1 B = 0 p1 = 17 p2 = 3 p = 20 B = 0 p = 19 B = 1 p = 17 B = 1 p = 15 B = 0 p = 11 B = 1 p = 9 B = 0 p = 5 B = 1 p = 3 B = 1 p1 = 19 p2 = 3 p = 98 B = 0 p = 97 B = 1 p = 95 B = 0 p = 93 B = 0 p = 89 B = 1 p = 87 B = 0 p = 83 B = 1 p = 81 B = 0 p = 77 B = 0 p = 71 B = 1 p = 69 B = 0 p = 63 B = 0 p = 59 B = 1 p = 57 B = 0 p = 53 B = 1 p = 47 B = 1 p = 41 B = 1 p = 39 B = 0 p = 33 B = 0 p = 29 B = 1 p = 27 B = 0 p = 21 B = 0 p = 17 B = 1 p = 11 B = 1 p = 3 B = 1 p1 = 97 p2 = 3 p = 100 B = 0 p = 99 B = 0 p = 97 B = 1 p = 95 B = 0 p = 91 B = 0 p = 89 B = 1 p = 85 B = 0 p = 83 B = 1 p = 79 B = 1 p = 73 B = 1 p = 71 B = 1 p = 65 B = 0 p = 61 B = 1 p = 59 B = 1 p = 55 B = 0 p = 49 B = 0 p = 43 B = 1 p = 41 B = 1 p = 35 B = 0 p = 31 B = 1 p = 29 B = 1 p = 23 B = 1 p = 19 B = 1 p = 13 B = 1 p = 5 B = 1 p = 1 B = 0 p1 = 97 p2 = 5 p = 112 B = 0 p = 111 B = 0 p = 109 B = 1 p = 107 B = 1 p = 103 B = 1 p = 101 B = 1 p = 97 B = 1 p = 95 B = 0 p = 91 B = 0 p = 85 B = 0 p = 83 B = 1 p = 77 B = 0 p = 73 B = 1 p = 71 B = 1 p = 67 B = 1 p = 61 B = 1 p = 55 B = 0 p = 53 B = 1 p = 47 B = 1 p = 43 B = 1 p = 41 B = 1 p = 35 B = 0 p = 31 B = 1 p = 25 B = 0 p = 17 B = 1 p = 13 B = 1 p = 11 B = 1 p = 7 B = 1 p = 5 B = 1 p = 1 B = 0 p1 = 109 p2 = 5 p = 998 B = 0 p = 997 B = 1 p = 995 B = 0 p = 993 B = 0 p = 989 B = 0 p = 987 B = 0 p = 983 B = 1 p = 981 B = 0 p = 977 B = 1 p = 971 B = 1 p = 969 B = 0 p = 963 B = 0 p = 959 B = 0 p = 957 B = 0 p = 953 B = 1 p = 947 B = 1 p = 941 B = 1 p = 939 B = 0 p = 933 B = 0 p = 929 B = 1 p = 927 B = 0 p = 921 B = 0 p = 917 B = 0 p = 911 B = 1 p = 903 B = 0 p = 899 B = 0 p = 897 B = 0 p = 893 B = 0 p = 891 B = 0 p = 887 B = 1 p = 873 B = 0 p = 869 B = 0 p = 863 B = 1 p = 861 B = 0 p = 851 B = 0 p = 849 B = 0 p = 843 B = 0 p = 837 B = 0 p = 833 B = 0 p = 827 B = 1 p = 821 B = 1 p = 819 B = 0 p = 809 B = 1 p = 807 B = 0 p = 803 B = 0 p = 801 B = 0 p = 789 B = 0 p = 777 B = 0 p = 773 B = 1 p = 771 B = 0 p = 767 B = 0 p = 761 B = 1 p = 759 B = 0 p = 749 B = 0 p = 743 B = 1 p = 737 B = 0 p = 731 B = 0 p = 729 B = 0 p = 723 B = 0 p = 719 B = 1 p = 717 B = 0 p = 707 B = 0 p = 693 B = 0 p = 689 B = 0 p = 687 B = 0 p = 683 B = 1 p = 669 B = 0 p = 663 B = 0 p = 653 B = 1 p = 651 B = 0 p = 647 B = 1 p = 641 B = 1 p = 633 B = 0 p = 627 B = 0 p = 621 B = 0 p = 617 B = 1 p = 611 B = 0 p = 603 B = 0 p = 599 B = 1 p = 591 B = 0 p = 581 B = 0 p = 579 B = 0 p = 569 B = 1 p = 567 B = 0 p = 561 B = 0 p = 557 B = 1 p = 551 B = 0 p = 543 B = 0 p = 539 B = 0 p = 537 B = 0 p = 533 B = 0 p = 521 B = 1 p = 513 B = 0 p = 509 B = 1 p = 501 B = 0 p = 497 B = 0 p = 491 B = 1 p = 479 B = 1 p = 477 B = 0 p = 459 B = 0 p = 453 B = 0 p = 443 B = 1 p = 437 B = 0 p = 431 B = 1 p = 429 B = 0 p = 423 B = 0 p = 413 B = 0 p = 407 B = 0 p = 401 B = 1 p = 399 B = 0 p = 393 B = 0 p = 387 B = 0 p = 383 B = 1 p = 381 B = 0 p = 369 B = 0 p = 359 B = 1 p = 357 B = 0 p = 353 B = 1 p = 347 B = 1 p = 341 B = 0 p = 339 B = 0 p = 327 B = 0 p = 323 B = 0 p = 317 B = 1 p = 309 B = 0 p = 299 B = 0 p = 291 B = 0 p = 281 B = 1 p = 273 B = 0 p = 267 B = 0 p = 261 B = 0 p = 257 B = 1 p = 249 B = 0 p = 243 B = 0 p = 239 B = 1 p = 231 B = 0 p = 227 B = 1 p = 213 B = 0 p = 203 B = 0 p = 191 B = 1 p = 189 B = 0 p = 179 B = 1 p = 177 B = 0 p = 173 B = 1 p = 171 B = 0 p = 161 B = 0 p = 147 B = 0 p = 143 B = 0 p = 141 B = 0 p = 137 B = 1 p = 123 B = 0 p = 119 B = 0 p = 117 B = 0 p = 113 B = 1 p = 93 B = 0 p = 89 B = 1 p = 81 B = 0 p = 71 B = 1 p = 63 B = 0 p = 59 B = 1 p = 53 B = 1 p = 47 B = 1 p = 33 B = 0 p = 29 B = 1 p = 23 B = 1 p = 17 B = 1 p = 9 B = 0 p = 3 B = 1 p1 = 997 p2 = 3 p = 1998 B = 0 p = 1997 B = 1 p = 1995 B = 0 p = 1993 B = 1 p = 1989 B = 0 p = 1987 B = 1 p = 1983 B = 0 p = 1981 B = 0 p = 1977 B = 0 p = 1971 B = 0 p = 1969 B = 0 p = 1963 B = 0 p = 1959 B = 0 p = 1957 B = 0 p = 1953 B = 0 p = 1947 B = 0 p = 1941 B = 0 p = 1939 B = 0 p = 1933 B = 1 p = 1929 B = 0 p = 1927 B = 0 p = 1921 B = 0 p = 1917 B = 0 p = 1911 B = 0 p = 1903 B = 0 p = 1899 B = 0 p = 1897 B = 0 p = 1893 B = 0 p = 1891 B = 0 p = 1887 B = 0 p = 1873 B = 1 p = 1869 B = 0 p = 1863 B = 0 p = 1861 B = 1 p = 1851 B = 0 p = 1849 B = 0 p = 1843 B = 0 p = 1837 B = 0 p = 1833 B = 0 p = 1827 B = 0 p = 1821 B = 0 p = 1819 B = 0 p = 1809 B = 0 p = 1807 B = 0 p = 1803 B = 0 p = 1801 B = 1 p = 1789 B = 1 p = 1777 B = 1 p = 1773 B = 0 p = 1771 B = 0 p = 1767 B = 0 p = 1761 B = 0 p = 1759 B = 1 p = 1749 B = 0 p = 1743 B = 0 p = 1737 B = 0 p = 1731 B = 0 p = 1729 B = 0 p = 1723 B = 1 p = 1719 B = 0 p = 1717 B = 0 p = 1707 B = 0 p = 1693 B = 1 p = 1689 B = 0 p = 1687 B = 0 p = 1683 B = 0 p = 1669 B = 1 p = 1663 B = 1 p = 1653 B = 0 p = 1651 B = 0 p = 1647 B = 0 p = 1641 B = 0 p = 1633 B = 0 p = 1627 B = 1 p = 1621 B = 1 p = 1617 B = 0 p = 1611 B = 0 p = 1603 B = 0 p = 1599 B = 0 p = 1591 B = 0 p = 1581 B = 0 p = 1579 B = 1 p = 1569 B = 0 p = 1567 B = 1 p = 1561 B = 0 p = 1557 B = 0 p = 1551 B = 0 p = 1543 B = 1 p = 1539 B = 0 p = 1537 B = 0 p = 1533 B = 0 p = 1521 B = 0 p = 1513 B = 0 p = 1509 B = 0 p = 1501 B = 0 p = 1497 B = 0 p = 1491 B = 0 p = 1479 B = 0 p = 1477 B = 0 p = 1459 B = 1 p = 1453 B = 1 p = 1443 B = 0 p = 1437 B = 0 p = 1431 B = 0 p = 1429 B = 1 p = 1423 B = 1 p = 1413 B = 0 p = 1407 B = 0 p = 1401 B = 0 p = 1399 B = 1 p = 1393 B = 0 p = 1387 B = 0 p = 1383 B = 0 p = 1381 B = 1 p = 1369 B = 0 p = 1359 B = 0 p = 1357 B = 0 p = 1353 B = 0 p = 1347 B = 0 p = 1341 B = 0 p = 1339 B = 0 p = 1327 B = 1 p = 1323 B = 0 p = 1317 B = 0 p = 1309 B = 0 p = 1299 B = 0 p = 1291 B = 1 p = 1281 B = 0 p = 1273 B = 0 p = 1267 B = 0 p = 1261 B = 0 p = 1257 B = 0 p = 1249 B = 1 p = 1243 B = 0 p = 1239 B = 0 p = 1231 B = 1 p = 1227 B = 0 p = ...