18 lines
356 B
Python
18 lines
356 B
Python
def summe(n) -> float:
|
|
lst = []
|
|
for i in range(1,n):
|
|
lst.append(i)
|
|
formatted = " + ".join(str(x) for x in lst)
|
|
print(f"summe = {formatted} ; sum = {total(lst)}")
|
|
|
|
def total(lst: list) -> float:
|
|
total = None
|
|
for i in lst:
|
|
i += total
|
|
if total:
|
|
return total
|
|
else:
|
|
return None
|
|
|
|
|
|
summe(10) |