summaryrefslogtreecommitdiff
path: root/sample/fact.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/fact.rb')
-rw-r--r--sample/fact.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/sample/fact.rb b/sample/fact.rb
new file mode 100644
index 0000000000..49678bc9d0
--- /dev/null
+++ b/sample/fact.rb
@@ -0,0 +1,8 @@
+def fact(n)
+ if n == 0
+ 1
+ else
+ n * fact(n-1)
+ end
+end
+print fact(ARGV[0].to_i), "\n"