sample/fact.rb


DEFINITIONS

This source file includes following functions.


   1  def fact(n)
   2    return 1 if n == 0
   3    f = 1
   4    while n>0
   5      f *= n
   6      n -= 1
   7    end
   8    return f
   9  end
  10  print fact(ARGV[0].to_i), "\n"