August 27, 2024
P40 - Goldbach’s conjecture.
Goldbach’s conjecture says that every positive even number greater than 2 is the sum of two prime numbers. E.g. 28=5+2328=5+23. It is one of the most famous facts in number theory that has not been proved to be correct in the general case.
It has been numerically confirmed up to very large numbers (much larger than Scala’s Int can represent). Write a function to find the two prime numbers that sum up to a given even integer.
scala
scala> 28.goldbach
res0: (Int, Int) = (5,23)