Created
March 19, 2020 22:50
-
-
Save houmanka/a2a07e559e1293934c136b09934f14ea to your computer and use it in GitHub Desktop.
AEM_sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule AncientEgyptianMultiplication do | |
require Integer | |
def sum_of([head | tail]) do | |
sum_of(tail, head) | |
end | |
def sum_of([], state), do: state | |
def sum_of([head | tail], state) do | |
sum_of(tail, state + head) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment