cours0708/P5B/ruby/exercices/factorielle.rb

17 lines
135 B
Ruby
Raw Normal View History

2008-11-25 21:11:16 +00:00
def fact(n)
if n == 0
then
1
else
res = 1
i = n
until i == 0
res = res * i
i = i - 1
end
res
end
end
puts fact(5)