0
fibonacci
i didnt know how to do the fibonacci project because I didn't quite well understand how recursion works I understand the base case but the rest is kinda blurry for me any tips
1 Antwort
+ 2
base case = case to stop recursion (loop by calling function itself), ok?
fibonacci rules: F(i) = F(i-1)+F(i-2), and F(0) = 0, F(1) = 1, right?
def fibonnacci(n):
if n < 0: raise Exception()
if n in (0,1): return n;
return fibonnacci(n-1)+fibonnacci(n-2)