Skip to content

Instantly share code, notes, and snippets.

@fenixbrassi
Created December 16, 2013 02:09
Show Gist options
  • Save fenixbrassi/7981402 to your computer and use it in GitHub Desktop.
Save fenixbrassi/7981402 to your computer and use it in GitHub Desktop.
Factorial
#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