summaryrefslogtreecommitdiff
path: root/sample/fib.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/fib.rb')
-rw-r--r--sample/fib.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/sample/fib.rb b/sample/fib.rb
new file mode 100644
index 0000000..c72f91f
--- /dev/null
+++ b/sample/fib.rb
@@ -0,0 +1,8 @@
+def fib (n)
+ if n<2
+ n
+ else
+ fib(n-2)+fib(n-1)
+ end
+end
+print(fib(20), "\n");