Skip to content

Instantly share code, notes, and snippets.

@houmanka
Created March 19, 2020 22:50
Show Gist options
  • Save houmanka/a2a07e559e1293934c136b09934f14ea to your computer and use it in GitHub Desktop.
Save houmanka/a2a07e559e1293934c136b09934f14ea to your computer and use it in GitHub Desktop.
AEM_sum
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