Last active
March 15, 2019 09:05
-
-
Save xavvvier/9a06fb01510ab7f029e75ce45be6d1fe to your computer and use it in GitHub Desktop.
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 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