cours0708/P5B/ruby/exercices/fact_iterareur.rb
2008-11-25 22:11:16 +01:00

17 lines
164 B
Ruby

def each_fact(n)
res = 1
for i in 0 .. n
res = res * i unless i == 0
yield(res)
end
res
end
res = 0
each_fact(10) do | i |
res = res + i
end
puts res