The Goldbach conjecture asserts that every even integer greater than 2 can be expressed as the sum of two primes.
Given the even integer n, return c, the number of different ways two primes can be added to result in n. Only count a pair once; the order is unimportant.
Example:
Input n = 10 Output c is 2
because of the prime pairs [3 7] and [5 5].
Input n = 50 Output c is 4
because of [3 47], [7 43], [13 37], and [19 31].
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers2413
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
52694 Solvers
-
Remove any row in which a NaN appears
8769 Solvers
-
7240 Solvers
-
Convert a numerical matrix into a cell array of strings
2381 Solvers
-
Check if number exists in vector
13801 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
For some reason the 'nthprime' function is not recognized, however it works for me in my desktop MATLAB.
@Dima Panna 'nthprime' uses symbolic math toolbox which is not supported in cody
I have used same solution approach as in goldbach conjecture part 1.