2016-05-13 02:26:52 +00:00
|
|
|
module SumOfMultiples exposing (..)
|
2015-10-13 18:23:46 +00:00
|
|
|
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2015-10-13 18:23:46 +00:00
|
|
|
sumOfMultiples : List Int -> Int -> Int
|
2016-03-17 01:38:51 +00:00
|
|
|
sumOfMultiples multiples limit =
|
2016-12-17 22:15:34 +00:00
|
|
|
List.sum (List.filter (inMultiples multiples) (List.range 1 (limit - 1)))
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2015-10-13 18:23:46 +00:00
|
|
|
|
2016-03-17 01:38:51 +00:00
|
|
|
inMultiples : List Int -> Int -> Bool
|
|
|
|
inMultiples multiples candidate =
|
2016-06-19 21:46:13 +00:00
|
|
|
List.any (\factor -> candidate % factor == 0) multiples
|