Cody

Problem 60. The Goldbach Conjecture

Solution 1863727

Submitted on 3 Jul 2019 by Ingrid Odlén
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

indexOfMin = 9 indexOfMin = 9 indexOfMin = 9 p1 = 5 p2 = 23 indexOfMin = 11 indexOfMin = 11 p1 = 3 p2 = 31 indexOfMin = 12 indexOfMin = 12 p1 = 3 p2 = 37 indexOfMin = 14 indexOfMin = 14 p1 = 3 p2 = 43 indexOfMin = 15 indexOfMin = 15 indexOfMin = 15 p1 = 5 p2 = 47 indexOfMin = 16 indexOfMin = 16 indexOfMin = 16 p1 = 5 p2 = 53 indexOfMin = 18 indexOfMin = 18 p1 = 3 p2 = 61 indexOfMin = 19 indexOfMin = 19 p1 = 3 p2 = 67 indexOfMin = 21 indexOfMin = 21 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

indexOfMin = 7 indexOfMin = 7 indexOfMin = 7 p1 = 5 p2 = 13 indexOfMin = 8 indexOfMin = 8 p1 = 3 p2 = 17 indexOfMin = 8 indexOfMin = 8 p1 = 3 p2 = 19 indexOfMin = 25 indexOfMin = 25 p1 = 3 p2 = 97 indexOfMin = 26 indexOfMin = 26 indexOfMin = 26 p1 = 5 p2 = 97 indexOfMin = 30 indexOfMin = 30 indexOfMin = 30 p1 = 5 p2 = 109 indexOfMin = 168 indexOfMin = 168 p1 = 3 p2 = 997 indexOfMin = 303 indexOfMin = 303 p1 = 3 p2 = 1997 indexOfMin = 11 indexOfMin = 11 indexOfMin = 11 p1 = 5 p2 = 31 indexOfMin = 503 indexOfMin = 503 indexOfMin = 503 indexOfMin = 503 p1 = 7 p2 = 3593