There was an error while loading. Please reload this page.
1 parent f6115e8 commit a587f7cCopy full SHA for a587f7c
1 file changed
Level_05/fibonacci.py
@@ -11,12 +11,14 @@
11
# siehe dazu https://github.com/pythonfoo/pythonfooLite/wiki/Rekursion_Vs._Iteration.
12
# Eine wesentlich perfomantere Version findet sich in Level 7.
13
14
+
15
def fib(n: int) -> int:
16
# Die ersten beiden Elemente sind fix:
17
if n <= 1:
18
return n
19
# Ansonsten: f(n) = f(n-1) + f(n-2)
- return fib(n-1) + fib(n-2)
20
+ return fib(n - 1) + fib(n - 2)
21
22
23
n = int(input("Welches Element soll berechnet werden? "))
24
print(" =>", fib(n))
0 commit comments