elm/exercises/sum-of-multiples/SumOfMultiples.example.elm

12 lines
323 B
Elm
Raw Permalink Normal View History

module SumOfMultiples exposing (..)
sumOfMultiples : List Int -> Int -> Int
sumOfMultiples multiples limit =
2016-12-17 22:15:34 +00:00
List.sum (List.filter (inMultiples multiples) (List.range 1 (limit - 1)))
inMultiples : List Int -> Int -> Bool
inMultiples multiples candidate =
List.any (\factor -> candidate % factor == 0) multiples