Cody

# Problem 60. The Goldbach Conjecture

Solution 2114925

Submitted on 2 Feb 2020 by Ishan Fernando
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

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

first = 5 second = 13 first = 7 second = 11 first = 11 second = 7 first = 13 second = 5 p1 = 13 p2 = 5 first = 3 second = 17 first = 7 second = 13 first = 13 second = 7 first = 17 second = 3 p1 = 17 p2 = 3 first = 3 second = 19 first = 5 second = 17 first = 11 second = 11 first = 17 second = 5 first = 19 second = 3 p1 = 19 p2 = 3 first = 3 second = 97 first = 11 second = 89 first = 17 second = 83 first = 29 second = 71 first = 41 second = 59 first = 47 second = 53 first = 53 second = 47 first = 59 second = 41 first = 71 second = 29 first = 83 second = 17 first = 89 second = 11 first = 97 second = 3 p1 = 97 p2 = 3 first = 5 second = 97 first = 13 second = 89 first = 19 second = 83 first = 23 second = 79 first = 29 second = 73 first = 31 second = 71 first = 41 second = 61 first = 43 second = 59 first = 59 second = 43 first = 61 second = 41 first = 71 second = 31 first = 73 second = 29 first = 79 second = 23 first = 83 second = 19 first = 89 second = 13 first = 97 second = 5 p1 = 97 p2 = 5 first = 5 second = 109 first = 7 second = 107 first = 11 second = 103 first = 13 second = 101 first = 17 second = 97 first = 31 second = 83 first = 41 second = 73 first = 43 second = 71 first = 47 second = 67 first = 53 second = 61 first = 61 second = 53 first = 67 second = 47 first = 71 second = 43 first = 73 second = 41 first = 83 second = 31 first = 97 second = 17 first = 101 second = 13 first = 103 second = 11 first = 107 second = 7 first = 109 second = 5 p1 = 109 p2 = 5 first = 3 second = 997 first = 17 second = 983 first = 23 second = 977 first = 29 second = 971 first = 47 second = 953 first = 53 second = 947 first = 59 second = 941 first = 71 second = 929 first = 89 second = 911 first = 113 second = 887 first = 137 second = 863 first = 173 second = 827 first = 179 second = 821 first = 191 second = 809 first = 227 second = 773 first = 239 second = 761 first = 257 second = 743 first = 281 second = 719 first = 317 second = 683 first = 347 second = 653 first = 353 second = 647 first = 359 second = 641 first = 383 second = 617 first = 401 second = 599 first = 431 second = 569 first = 443 second = 557 first = 479 second = 521 first = 491 second = 509 first = 509 second = 491 first = 521 second = 479 first = 557 second = 443 first = 569 second = 431 first = 599 second = 401 first = 617 second = 383 first = 641 second = 359 first = 647 second = 353 first = 653 second = 347 first = 683 second = 317 first = 719 second = 281 first = 743 second = 257 first = 761 second = 239 first = 773 second = 227 first = 809 second = 191 first = 821 second = 179 first = 827 second = 173 first = 863 second = 137 first = 887 second = 113 first = 911 second = 89 first = 929 second = 71 first = 941 second = 59 first = 947 second = 53 first = 953 second = 47 first = 971 second = 29 first = 977 second = 23 first = 983 second = 17 first = 997 second = 3 p1 = 997 p2 = 3 first = 3 second = 1997 first = 7 second = 1993 first = 13 second = 1987 first = 67 second = 1933 first = 127 second = 1873 first = 139 second = 1861 first = 199 second = 1801 first = 211 second = 1789 first = 223 second = 1777 first = 241 second = 1759 first = 277 second = 1723 first = 307 second = 1693 first = 331 second = 1669 first = 337 second = 1663 first = 373 second = 1627 first = 379 second = 1621 first = 421 second = 1579 first = 433 second = 1567 first = 457 second = 1543 first = 541 second = 1459 first = 547 second = 1453 first = 571 second = 1429 first = 577 second = 1423 first = 601 second = 1399 first = 619 second = 1381 first = 673 second = 1327 first = 709 second = 1291 first = 751 second = 1249 first = 769 second = 1231 first = 787 second = 1213 first = 829 second = 1171 first = 877 second = 1123 first = 883 second = 1117 first = 907 second = 1093 first = 937 second = 1063 first = 967 second = 1033 first = 991 second = 1009 first = 1009 second = 991 first = 1033 second = 967 first = 1063 second = 937 first = 1093 second = 907 first = 1117 second = 883 first = 1123 second = 877 first = 1171 second = 829 first = 1213 second = 787 first = 1231 second = 769 first = 1249 second = 751 first = 1291 second = 709 first = 1327 second = 673 first = 1381 second = 619 first = 1399 second = 601 first = 1423 second = 577 first = 1429 second = 571 first = 1453 second = 547 first = 1459 second = 541 first = 1543 second = 457 first = 1567 second = 433 first = 1579 second = 421 first = 1621 second = 379 first = 1627 second = 373 first = 1663 second = 337 first = 1669 second = 331 first = 1693 second = 307 first = 1723 second = 277 first = 1759 second = 241 first = 1777 second = 223 first = 1789 second = 211 first = 1801 second = 199 first = 1861 second = 139 first = 1873 second = 127 first = 1933 second = 67 first = 1987 second = 13 first = 1993 second = 7 first = 1997 second = 3 p1 = 1997 p2 = 3 first = 5 second = 31 first = 7 second = 29 first = 13 second = 23 first = 17 second = 19 first = 19 second = 17 first = 23 second = 13 first = 29 second = 7 first = 31 second = 5 p1 = 31 p2 = 5 first = 7 second = 3593 first = 17 second = 3583 first = 19 second = 3581 first = 29 second = 3571 first = 41 second = 3559 first = 43 second = 3557 first = 53 second = 3547 first = 59 second = 3541 first = 61 second = 3539 first = 67 second = 3533 first = 71 second = 3529 first = 73 second = 3527 first = 83 second = 3517 first = 89 second = 3511 first = 101 second = 3499 first = 109 second = 3491 first = 131 second = 3469 first = 137 second = 3463 first = 139 second = 3461 first = 151 second = 3449 first = 167 second = 3433 first = 193 second = 3407 first = 211 second = 3389 first = 227 second = 3373 first = 229 second = 3371 first = 239 second = 3361 first = 241 second = 3359 first = 257 second = 3343 first = 269 second = 3331 first = 271 second = 3329 first = 277 second = 3323 first = 281 second = 3319 first = 293 second = 3307 first = 347 second = 3253 first = 349 second = 3251 first = 379 second = 3221 first = 383 second = 3217 first = 397 second = 3203 first = 409 second = 3191 first = 419 second = 3181 first = 431 second = 3169 first = 433 second = 3167 first = 463 second = 3137 first = 479 second = 3121 first = 491 second ...

### Community Treasure Hunt

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

Start Hunting!