Fibonacci-Zahlen durch Rekursion (ohne Currying)
This commit is contained in:
parent
7906360a15
commit
cbe6432e1f
17
algorithmen/fibonacci.py
Normal file
17
algorithmen/fibonacci.py
Normal file
@ -0,0 +1,17 @@
|
||||
def fibo(n):
|
||||
if n == 0:
|
||||
return 0
|
||||
elif n == 1:
|
||||
return 1
|
||||
elif n == 2:
|
||||
return 1
|
||||
else:
|
||||
f1 = fibo(n-1)
|
||||
f2 = fibo(n-2)
|
||||
return f1 + f2
|
||||
|
||||
for i in range(30):
|
||||
f = fibo(i)
|
||||
print(f)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user