1998-01-16 12:13:05 +00:00
|
|
|
def fact(n)
|
1998-01-16 12:19:22 +00:00
|
|
|
return 1 if n == 0
|
|
|
|
f = 1
|
2002-12-19 20:42:50 +00:00
|
|
|
n.downto(1) do |i|
|
|
|
|
f *= i
|
1998-01-16 12:13:05 +00:00
|
|
|
end
|
1998-01-16 12:19:22 +00:00
|
|
|
return f
|
1998-01-16 12:13:05 +00:00
|
|
|
end
|
|
|
|
print fact(ARGV[0].to_i), "\n"
|