Project Euler Problem 46 Solution

Question

It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.

9=7+2×1215=7+2×2221=3+2×3225=7+2×3227=19+2×2233=31+2×12\begin{aligned} 9 & = 7 + 2\times1^2 \\ 15 & = 7 + 2\times2^2 \\ 21 & = 3 + 2\times3^2 \\ 25 & = 7 + 2\times3^2 \\ 27 & = 19 + 2\times2^2 \\ 33 & = 31 + 2\times1^2 \end{aligned}

It turns out that the conjecture was false.

What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?

Haskell

Python

Ruby