This commit is contained in:
alstergym
2026-09-22 10:14:38 +02:00
parent f8c024b2ec
commit 56ac384fbe
4 changed files with 122 additions and 47 deletions
+13 -2
View File
@@ -6,7 +6,7 @@ def fakultaet(n):
else:
return n * fakultaet(n-1)
print(fakultaet(int(input("Geben Sie eine Zahl ein: "))))
#print(fakultaet(int(input("Geben Sie eine Zahl ein: "))))
# FIBONACCI REKURSION
# Aufgabe 2
@@ -18,4 +18,15 @@ def fibonacci(n):
else:
return fibonacci(n-1) + fibonacci(n-2)
print(fibonacci(int(input("Geben Sie eine Zahl ein: "))))
#print(fibonacci(int(input("Geben Sie eine Zahl ein: "))))
#Rekursive Berechnung der Fibonacci-Zahlen
def fibonacci_recursive(n):
if n <= 0:
return 0
elif n == 1:
return 1
else:
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
print(fibonacci_recursive(int(input("Geben Sie eine Zahl ein: "))))