#!/usr/bin/python
def sum_seq (n):
result = 0
for i in range (n+1):
result += i
print(i)
return result
def gauss_f (n):
halve = n / 2
print(halve)
result = int (n * halve + halve)
return result
try:
user_input = input() or "100"
user_input = int (user_input )
except:
print ("wrong input")
print ("Result set to default")
user_input = 100
finally:
calc1 = sum_seq(user_input)
calc2 = gauss_f(user_input)
print ("sum Sequence from 0 to n")
print("Result\n")
print (f"your input = {user_input}")
print (f"forloop result {calc1=}")
print (f"Karl gauss result {calc2=}")
Comments