Created
September 28, 2015 05:06
-
-
Save zahodi/9254afb5c6b5862c45a0 to your computer and use it in GitHub Desktop.
factorial
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
#!/usr/bin/env ruby | |
def countdown(n) | |
if n == 0 | |
1 | |
else | |
n*countdown(n-1) | |
end | |
end | |
puts countdown(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment