12 lines
365 B
Haskell
12 lines
365 B
Haskell
-- What is the smallest odd composite that cannot be written as the sum of a
|
|
-- prime and twice a square?
|
|
|
|
import Euler
|
|
|
|
composites = [1..] \\\ primes
|
|
isTwiceSquare n = 2 * ((floor $ sqrt $ (/ 2) $ fromIntegral n) ^ 2) == n
|
|
|
|
main = print $ head $ do
|
|
n <- tail $ filter odd composites
|
|
n <$ (guard $ not $ any isTwiceSquare $ map (n-) $ takeWhile (< n) primes)
|