aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--entries/patricebelleville/fib.py13
-rw-r--r--people.json10
2 files changed, 23 insertions, 0 deletions
diff --git a/entries/patricebelleville/fib.py b/entries/patricebelleville/fib.py
new file mode 100644
index 0000000..767ce11
--- /dev/null
+++ b/entries/patricebelleville/fib.py
@@ -0,0 +1,13 @@
+def fibonacci(n):
+ return fib_helper(n, 0, 1)
+
+def fib_helper(n, prev, curr):
+ # Base cases
+ if n < 0:
+ raise ValueError('Negative argument to fibonnaci')
+ if n == 0:
+ return prev
+ if n == 1:
+ return curr
+ return fib_helper(n-1, curr, prev + curr)
+
diff --git a/people.json b/people.json
index d611699..a6ef1d5 100644
--- a/people.json
+++ b/people.json
@@ -256,6 +256,16 @@
]
},
{
+ "name": "Patrice Belleville",
+ "title": "Associate Professor of Teaching, Computer Science, UBC",
+ "entries": [
+ {
+ "name": "fib",
+ "link": "./entries/patricebelleville/fib.py"
+ }
+ ]
+ },
+ {
"github": "perryliao",
"name": "Perry Liao",
"title": "BSc, UBC",