Le 29 septembre 21:26, F. Senault a ñÄrit :

And I forgot a simple, classic, one :

def factorial(n)
  (1..n).inject(1) { |p, f| p * f }
end

def factorial(n)
  (1..n).inject(1, :*)
end

(I don't like much the second one, it's a bit less legible.)

Fred
-- 
When my body starts to shiver from the chill of  The scarlett sweat
When my lips eclipse the sun and the moon  Reflecting from the wet  When
the blood of my love outraces  Every one of the stallions in your pack -
that's when  U go, u go, u go 2 the max                (Prince, The Max)