mirror of
https://github.com/correl/elm.git
synced 2024-11-17 03:00:06 +00:00
9 lines
341 B
Elm
9 lines
341 B
Elm
module SumOfMultiplesExample where
|
|
|
|
sumOfMultiples : List Int -> Int -> Int
|
|
sumOfMultiples factors upperLimit =
|
|
List.sum (List.filter (isMultipleOfAnyFactor factors) [1 .. (upperLimit - 1)])
|
|
|
|
isMultipleOfAnyFactor : List Int -> Int -> Bool
|
|
isMultipleOfAnyFactor factors candidate =
|
|
List.any (\factor -> candidate % factor == 0) factors
|