diff --git a/Haskell/p023.hs b/Haskell/p023.hs index 44bb637..67e64e9 100644 --- a/Haskell/p023.hs +++ b/Haskell/p023.hs @@ -10,6 +10,7 @@ -- -- Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. import Data.List +import qualified Data.Set as Set import ProjectEuler (sumProperDivisors) @@ -17,7 +18,7 @@ isAbundant :: (Integral a) => a -> Bool isAbundant n = sumProperDivisors n > n abundantSums :: (Integral a) => [a] -abundantSums = nub [ x + y | x <- abundantList, y <- abundantList, x + y <= 28123, y >= x ] +abundantSums = Set.toList $ Set.fromList [ x + y | x <- abundantList, y <- abundantList, x + y <= 28123, y >= x ] where abundantList = [ x | x <- [12..28123], isAbundant x ] sumNotAbundant :: (Integral a) => a