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

12 lines
309 B
Text
Raw Normal View History

module SumOfMultiples exposing (..)
sumOfMultiples : List Int -> Int -> Int
sumOfMultiples multiples limit =
List.sum (List.filter (inMultiples multiples) [1..(limit - 1)])
inMultiples : List Int -> Int -> Bool
inMultiples multiples candidate =
List.any (\factor -> candidate % factor == 0) multiples