1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/sample/fact.rb
2019-08-17 14:56:57 +09:00

9 lines
111 B
Ruby

def fact(n)
return 1 if n == 0
f = 1
n.downto(1) do |i|
f *= i
end
f
end
puts fact(ARGV[0].to_i)