Problem 60739. Explore the twin prime Goldbach conjecture
The Goldbach conjecture says that every positive even integer greater than 2 can be expressed as the sum of two prime numbers in at least one way. For example, 16 is 3+13, 48 is 5+43, and 210 is 19+191. In these examples, the prime numbers are twin primes, or prime numbers that are 2 away from another prime—for example, 3 and 5, 11 and 13, 41 and 43, 17 and 19, and 191 and 193.
In fact, as far as we know, all but 35 even numbers can be written as the sum of twin primes. This statement can be called the “twin prime Goldbach conjecture.” The exceptions have an interesting pattern, especially if zero is allowed.
Write a function that takes an even number n as input and produces all pairs of twin primes that sum to n. The output should be a two-column matrix with the smaller of the pair in the first column and sorted by the first column. For example, the input 16 should produce [3 13; 5 11]; notice that [11 5] and [13 3] are not included. If the number cannot be written as the sum of twin primes, return [].
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems
More from this Author279
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!