Skip to content

Instantly share code, notes, and snippets.

@shahryarjb
Created April 21, 2017 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahryarjb/4ed328d871870a2885621c57f03437bf to your computer and use it in GitHub Desktop.
Save shahryarjb/4ed328d871870a2885621c57f03437bf to your computer and use it in GitHub Desktop.
# my blog : https://trangell.com/fa/
# public : http://iranonrails.ir
defmodule Factorial do
def of(0), do: 1
def of(n), do: n * of(n - 1)
end
@shahryarjb
Copy link
Author


defmodule Factorial do
  def of(0), do: 1
  def of(n) when n > 0 do
    n * of(n-1)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment