Logo
Explore Help
Sign In
1berry/ruby
1
0
Fork 0
You've already forked ruby
Code Issues Packages Projects Releases Wiki Activity
ruby/sample/fact.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

10 lines
111 B
Ruby
Raw Permalink Normal View History

Initial revision git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1998-01-16 12:13:05 +00:00
def fact(n)
This commit was generated by cvs2svn to compensate for changes in r11, which included commits to RCS files with non-trunk default branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1998-01-16 12:19:22 +00:00
return 1 if n == 0
f = 1
Improve. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-19 20:42:50 +00:00
n.downto(1) do |i|
f *= i
Initial revision git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1998-01-16 12:13:05 +00:00
end
Simplify a sample code (#2374)
2019-08-17 14:56:57 +09:00
f
Initial revision git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1998-01-16 12:13:05 +00:00
end
Simplify a sample code (#2374)
2019-08-17 14:56:57 +09:00
puts fact(ARGV[0].to_i)
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 3230ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API