Skip to content

Instantly share code, notes, and snippets.

@xavvvier
Last active March 15, 2019 09:05
Show Gist options
  • Save xavvvier/9a06fb01510ab7f029e75ce45be6d1fe to your computer and use it in GitHub Desktop.
Save xavvvier/9a06fb01510ab7f029e75ce45be6d1fe to your computer and use it in GitHub Desktop.
defmodule Factorial do
def of(number) do
of(number, 1)
end
defp of(n, product) when n<= 1 do
product
end
defp of(number, product) do
of(number-1, product * number)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment