Cody

# Problem 60. The Goldbach Conjecture

Solution 209273

Submitted on 27 Feb 2013 by Muthu Annamalai
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

ans = 15 13 p1 = 15 p2 = 13 ans = 13 15 ans = 11 17 p1 = 11 p2 = 17 p1 = 11 p2 = 17 ans = 17 17 p1 = 17 p1 = 17 p2 = 17 ans = 21 19 p1 = 21 p2 = 19 ans = 19 21 ans = 17 23 p1 = 17 p2 = 23 p1 = 17 p2 = 23 ans = 23 23 p1 = 23 p1 = 23 p2 = 23 ans = 27 25 p1 = 27 p2 = 25 ans = 25 27 ans = 23 29 p1 = 23 p2 = 29 p1 = 23 p2 = 29 ans = 29 29 p1 = 29 p1 = 29 p2 = 29 ans = 33 31 p1 = 33 p2 = 31 ans = 31 33 ans = 29 35 p1 = 29 p2 = 35 ans = 27 37 p1 = 27 p2 = 37 ans = 25 39 p1 = 25 p2 = 39 ans = 23 41 p1 = 23 p2 = 41 p1 = 23 p2 = 41 ans = 35 35 p1 = 35 ans = 33 37 p1 = 33 p2 = 37 ans = 31 39 p1 = 31 p2 = 39 ans = 29 41 p1 = 29 p2 = 41 p1 = 29 p2 = 41 ans = 39 37 p1 = 39 p2 = 37 ans = 37 39 ans = 35 41 p1 = 35 p2 = 41 ans = 33 43 p1 = 33 p2 = 43 ans = 31 45 p1 = 31 p2 = 45 ans = 29 47 p1 = 29 p2 = 47 p1 = 29 p2 = 47

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

ans = 9 9 p1 = 9 ans = 7 11 p1 = 7 p2 = 11 p1 = 7 p2 = 11 ans = 11 9 p1 = 11 p2 = 9 ans = 9 11 ans = 7 13 p1 = 7 p2 = 13 p1 = 7 p2 = 13 ans = 11 11 p1 = 11 p1 = 11 p2 = 11 ans = 51 49 p1 = 51 p2 = 49 ans = 49 51 ans = 47 53 p1 = 47 p2 = 53 p1 = 47 p2 = 53 ans = 51 51 p1 = 51 ans = 49 53 p1 = 49 p2 = 53 ans = 47 55 p1 = 47 p2 = 55 ans = 45 57 p1 = 45 p2 = 57 ans = 43 59 p1 = 43 p2 = 59 p1 = 43 p2 = 59 ans = 57 57 p1 = 57 ans = 55 59 p1 = 55 p2 = 59 ans = 53 61 p1 = 53 p2 = 61 p1 = 53 p2 = 61 ans = 501 499 p1 = 501 p2 = 499 ans = 499 501 ans = 497 503 p1 = 497 p2 = 503 ans = 495 505 p1 = 495 p2 = 505 ans = 493 507 p1 = 493 p2 = 507 ans = 491 509 p1 = 491 p2 = 509 p1 = 491 p2 = 509 ans = 1001 999 p1 = 1001 p2 = 999 ans = 999 1001 ans = 997 1003 p1 = 997 p2 = 1003 ans = 995 1005 p1 = 995 p2 = 1005 ans = 993 1007 p1 = 993 p2 = 1007 ans = 991 1009 p1 = 991 p2 = 1009 p1 = 991 p2 = 1009 ans = 19 17 p1 = 19 p2 = 17 p1 = 19 p2 = 17 ans = 1801 1799 p1 = 1801 p2 = 1799 ans = 1799 1801 ans = 1797 1803 p1 = 1797 p2 = 1803 ans = 1795 1805 p1 = 1795 p2 = 1805 ans = 1793 1807 p1 = 1793 p2 = 1807 ans = 1791 1809 p1 = 1791 p2 = 1809 ans = 1789 1811 p1 = 1789 p2 = 1811 p1 = 1789 p2 = 1811