euler/Problem052.hs

15 lines
424 B
Haskell

-- It can be seen that the number, 125874, and its double, 251748, contain
-- exactly the same digits, but in a different order.
--
-- Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
-- contain the same digits.
import Euler
import Debug.Trace
main = print $ head $ do
n <- [1..]
let xs = map (sort . toDigits . (n *)) [2,3,4,5,6] :: [[Int]]
guard $ all (== head xs) (tail xs)
return n