first commit
This commit is contained in:
53
Ugesedler/Ugeseddel-9-05-11-2025/src/OpgaverFormiddag.py
Normal file
53
Ugesedler/Ugeseddel-9-05-11-2025/src/OpgaverFormiddag.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import math
|
||||
|
||||
def f1(n):
|
||||
if n<= 1:
|
||||
print(n, sep="", end="")
|
||||
else:
|
||||
f1(int(n/2))
|
||||
print(", ", n, sep="", end="")
|
||||
|
||||
#f1(10)
|
||||
#print()
|
||||
|
||||
def f2(n: int):
|
||||
if n >= 100:
|
||||
print(n, sep="", end="")
|
||||
else:
|
||||
f2(2*n)
|
||||
print(", ", n, sep="", end="")
|
||||
|
||||
#f2(10)
|
||||
#print()
|
||||
|
||||
def f3(n: int):
|
||||
if n <= 0:
|
||||
print("*", sep="", end="")
|
||||
elif n % 2 == 0:
|
||||
print("(", sep="", end="")
|
||||
f3(n-1)
|
||||
print(")", sep="", end="")
|
||||
else:
|
||||
print("[", sep="", end="")
|
||||
f3(n-1)
|
||||
print("]", sep="", end="")
|
||||
#f3(2)
|
||||
#print()
|
||||
|
||||
def process(a):
|
||||
return a if len(a) <= 1 else process(a[math.floor(len(a)/2):]) + process(a[:math.floor(len(a)/2)]) # Reverser arrayet
|
||||
|
||||
liste = [1,2,3,4,5,6,7,8,9,10]
|
||||
print(process(liste))
|
||||
print()
|
||||
|
||||
def next_fib(a):
|
||||
return a if len(a)<=1 else a.append(a[-2]+a[-1])
|
||||
|
||||
def main_fib():
|
||||
fib_liste = [0, 1]
|
||||
for i in range(50):
|
||||
next_fib(fib_liste)
|
||||
print(fib_liste)
|
||||
|
||||
main_fib()
|
||||
Reference in New Issue
Block a user