21 lines
443 B
Python
21 lines
443 B
Python
# FAKULTÄTEN REKURSION
|
|
# Aufgabe 1
|
|
def fakultaet(n):
|
|
if n == 0:
|
|
return 1
|
|
else:
|
|
return n * fakultaet(n-1)
|
|
|
|
print(fakultaet(int(input("Geben Sie eine Zahl ein: "))))
|
|
|
|
# FIBONACCI REKURSION
|
|
# Aufgabe 2
|
|
def fibonacci(n):
|
|
if n == 0:
|
|
return 0
|
|
elif n == 1:
|
|
return 1
|
|
else:
|
|
return fibonacci(n-1) + fibonacci(n-2)
|
|
|
|
print(fibonacci(int(input("Geben Sie eine Zahl ein: ")))) |