Skip to content

Instantly share code, notes, and snippets.

@jonathanpike
Created October 15, 2015 19:38
Show Gist options
  • Save jonathanpike/cccf701be11b8741424a to your computer and use it in GitHub Desktop.
Save jonathanpike/cccf701be11b8741424a to your computer and use it in GitHub Desktop.
def factorial(n)
if n == 0
return 1
else
i = n - 1
while i > 0
n *= i
i -= 1
end
end
return n
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment