1 def factorial(n)
   2   if n == 1
   3     return 1
   4   else
   5     return n * factorial(n-1)
   6   end
   7 end
   8 
   9 def factorial2(n)
  10   n == 1 ? 1 : n * factorial(n-1)
  11 end

Factorial.rb (last edited 2011-08-03 11:00:55 by localhost)

web biohackers.net