summaryrefslogtreecommitdiff
path: root/sample/fact.rb
blob: d8147a40f15262cc5331c7130a78a5fef3a8e472 (plain)
1
2
3
4
5
6
7
8
9
def fact(n)
  return 1 if n == 0
  f = 1
  n.downto(1) do |i|
    f *= i
  end
  return f
end
print fact(ARGV[0].to_i), "\n"
/td> 2012-10-19vm.c: pass through thrown objectsnobu 2012-10-02* error.c (exc_to_s, name_err_to_s, name_err_mesg_to_str): do notshugo 2012-08-08* compile.c, insns.def (checkmatch):ko1 2012-08-06test_exception.rb: split testsnobu 2012-08-06test_exception.rb: use local variablesnobu 2012-03-16suppress warning.nobu 2012-03-16fix indentnobu 2012-03-16Tempfile#opennobu 2012-01-14* error.c (exc_equal): clear rb_thread_t::errinfo when ignorenagachika 2012-01-14* error.c (exc_equal): ignore exceptions during implicitnobu 2012-01-13Revert "* error.c (exc_equal): try implicit conversion for delegator."naruse 2012-01-13* error.c (exc_equal): try implicit conversion for delegator.nobu 2011-12-13* error.c (name_err_mesg_to_str): clear rb_thread_t::errinfo whennagachika 2011-12-11* error.c (exit_initialize): deal with true and false as well asnobu 2011-12-08update doc and add test for SystemExit.new.akr 2011-12-07* vm.c (vm_set_top_stack, vm_set_eval_stack): check for stacknobu 2011-09-12* test/ruby/test_exception.rb (TestException#test_exit_success_p):nobu 2010-10-11* error.c (syserr_initialize): set the encoding of Errno::*#messagenaruse 2010-05-04* error.c (name_err_mesg_to_str): preserve encoding of inspection.nobu 2010-01-27* test/ruby/test_exception.rbkazu 2010-01-22* test/ruby/test_array.rb: add a test for Array#rotate, rotate!.mame 2010-01-05* test/ruby/test_exception.rb: add a test. cf [ruby-dev:39116]kazu 2009-07-16* id.c (Init_id), vm.c (vm_exec): @#__ThrowState__ is no longernobu 2008-09-24* test: assert_raises has been deprecated since a long time ago.nobu 2008-07-15* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err): newmame 2008-05-14* test/ruby/test_object.rb: new tests to achieve over 90% testmame