Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @spec to(non_neg_integer, [non_neg_integer]) :: non_neg_integer
- def to(limit, [h | t] = factors) do
- factors
- |> Enum.map(&make_list(limit, &1, &1, []))
- |> List.flatten
- |> &calculate_sum()
- end
- def calculate_sum([]), do: 0
- def calculate_sum(list) do
- list
- |> Enum.uniq
- |> Enum.reduce(&+/2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement