13 lines
416 B
Haskell
13 lines
416 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?
|
|
|
|
import Euler
|
|
|
|
pandigitals = map fromDigits $ go 9
|
|
where go 0 = []; go n = reverse (sort (permutations [1..n])) ++ go (n-1)
|
|
|
|
main = print $ head $ filter isPrime pandigitals
|