22.09.26
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
def fakultaet(n):
|
||||||
|
if n == 0:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return n * fakultaet(n - 1)
|
||||||
|
|
||||||
|
|
||||||
|
zahl = 12
|
||||||
|
print("Die Fakultät von", zahl, "ist:", fakultaet(zahl))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def fibonacci(n):
|
||||||
|
if n == 0:
|
||||||
|
return 0
|
||||||
|
elif n == 1:
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return fibonacci(n - 1) + fibonacci(n - 2)
|
||||||
|
|
||||||
|
|
||||||
|
zahl = 8
|
||||||
|
print("Fib(", zahl, ") =", fibonacci(zahl))
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import turtle
|
||||||
|
|
||||||
|
#def zeichnen(n):
|
||||||
|
# if n > 0:
|
||||||
|
# turtle.forward(300)
|
||||||
|
# turtle.left(75)
|
||||||
|
# turtle.forward(150)
|
||||||
|
# turtle.backward(150)
|
||||||
|
# zeichnen(n - 1)
|
||||||
|
|
||||||
|
#zeichnen(2)
|
||||||
|
|
||||||
|
#turtle.mainloop()
|
||||||
|
|
||||||
|
#def zeichnen(n):
|
||||||
|
# if n == 0:
|
||||||
|
# return
|
||||||
|
|
||||||
|
# turtle.forward(100)
|
||||||
|
# zeichnen(n - 1)
|
||||||
|
|
||||||
|
#turtle.left(90)
|
||||||
|
#turtle.forward(200)
|
||||||
|
#turtle.left(45)
|
||||||
|
|
||||||
|
#zeichnen(1)
|
||||||
|
|
||||||
|
#turtle.backward(100)
|
||||||
|
#turtle.right(90)
|
||||||
|
|
||||||
|
#zeichnen(1)
|
||||||
|
|
||||||
|
#turtle.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
def baum(laenge):
|
||||||
|
if laenge < 20:
|
||||||
|
return
|
||||||
|
|
||||||
|
turtle.forward(laenge)
|
||||||
|
|
||||||
|
turtle.left(45)
|
||||||
|
baum(laenge * 0.5)
|
||||||
|
|
||||||
|
turtle.right(90)
|
||||||
|
baum(laenge * 0.5)
|
||||||
|
|
||||||
|
turtle.left(45)
|
||||||
|
turtle.backward(laenge)
|
||||||
|
|
||||||
|
|
||||||
|
turtle.left(90)
|
||||||
|
baum(100)
|
||||||
|
|
||||||
|
turtle.mainloop()
|
||||||
Reference in New Issue
Block a user