summaryrefslogtreecommitdiff
path: root/algorithms/fibonacci.py
diff options
context:
space:
mode:
Diffstat (limited to 'algorithms/fibonacci.py')
-rwxr-xr-xalgorithms/fibonacci.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/algorithms/fibonacci.py b/algorithms/fibonacci.py
new file mode 100755
index 0000000..5912de0
--- /dev/null
+++ b/algorithms/fibonacci.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python2
+
+
+def fib(n):
+ if n == 0:
+ return 0
+ elif n == 1:
+ return 1
+ else:
+ return fib(n-1) + fib(n-2)
+
+print fib(20)
+