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