Created
December 16, 2013 02:09
-
-
Save fenixbrassi/7981402 to your computer and use it in GitHub Desktop.
Factorial
This file contains 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
#factorial | |
def factorial(x) | |
if x <= 1 | |
return 1 | |
else | |
x * factorial(x - 1) | |
end | |
end | |
puts "give me the number" | |
x = gets | |
puts "the factorial of " + x + " is : " + factorial | |
(x.to_i).to_s | |
.------------------ | |
result in console | |
give me the number | |
100 | |
the factorial of 100 | |
is : 93326215443944152681699238856266700490715968264381621468592963895217599993 | |
22991560894146397615651828625369792082722375825118521091686400000000000000000000 | |
0000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment