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 primes p1 and p2 that satisfy the condition n = p1 + p2. Note that the primes are not always unique. The test is not sensitive to order or uniqueness. You just need to meet the appropriate conditions.
Example:
Input n = 286
Output (any of the following is acceptable)
[ 3 283]
[283 3]
[ 5 281]
[107 179]
[137 149]
Solution Stats
Problem Comments
16 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers5996
Suggested Problems
-
Arrange Vector in descending order
14220 Solvers
-
Find the dimensions of a matrix
570 Solvers
-
1008 Solvers
-
Find the Oldest Person in a Room
21722 Solvers
-
calculate the length of matrix
2652 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 n =10,p1=[3 5 7],p2=[7 5 3],is the correct answer. but the judgement is not allowed.
Nice one.
Thank you very much! Its a really nice one!
Well made. I am still trimming down my code furiously. My favorite problem so far.
Currently the best one for me!
nice problem . I like problem related to prime numbers
Very nice problem!
this was a fun one
something I am doing worng.
please help.
p1=[]
p2=[]
for i = 1:5000
x1 = ceil(286*rand(1));
x2 = ceil(286*rand(1));
s = x1+x2;
a =isprime(x1);
b=isprime(x2);
if a==1 && b==1 && s ==n
p1=x1
p2=x2
end
end
[p1 p2]
cool
有中国的小伙伴吗?
Really interesting the Goldbach conjecture!
有中国的小伙伴呀
At first,I thought I should find all the possible answers.But I misunderstood the text............
nice question
perfect nice