Problem 56190. Split Even Number Into Two Primes
Given an even whole number n (> 2), return a 2-element vector of primes, p, such that p(1) + p(2) = n. The elements of p should be in increasing numerical order (that is, p(1) <= p(2)).
Fun note: technically it cannot be guaranteed that such primes exist for any n. However, although Goldbach's Conjecture has not been formally proven, it has been verified for all n well beyond any you'll face in this problem.
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
Dyuman Joshi
on 12 Apr 2023
Test cases have been added to the problem.
Filip
on 7 Jan 2024
It is a really nice tasks. However, The test cases or the task description can be improved. E.g. for n = 18 the answer can be a vector [5 13] or [13 5]. However, [13 5] is not "correct" according to the test. So in the task description can be written to return the numbers in ascending order or test cases should take any order of the 2 element vector
Matt Tearle
on 23 Feb 2024
Thanks for that catch, Filip. I added the ordering to the problem description.
Solution Comments
Show commentsProblem Recent Solvers198
Suggested Problems
-
107152 Solvers
-
1694 Solvers
-
Back to basics 8 - Matrix Diagonals
941 Solvers
-
910 Solvers
-
Find nearest prime number less than input number
868 Solvers
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!