22 lines
646 B
Haskell
22 lines
646 B
Haskell
-- We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital
|
|
-- and is also prime.
|
|
--
|
|
-- What is the largest n-digit pandigital prime that exists?
|
|
|
|
module P041 (p041) where
|
|
|
|
import Data.List (uncons)
|
|
import Data.Maybe (fromJust)
|
|
import ProjectEuler (isPandigital, isPrime)
|
|
|
|
maxPandigitalPrime :: Integer
|
|
maxPandigitalPrime = fst . fromJust $ uncons $ filter isPrime (filter isPandigital [7654321, 7654319 ..])
|
|
|
|
p041 :: IO ()
|
|
p041 = do
|
|
let result = maxPandigitalPrime
|
|
putStrLn $
|
|
"Project Euler, Problem 41\n"
|
|
++ "Answer: "
|
|
++ show result
|