Take an even number between 10 and 50 from the user as input. Calculate the sum of all numbers from 1 till the input number. Make sure the necessary are checks are placed for while taking input.
n = int(input())
if 10 <=n <= 50 and n%2 == 0:
s = 0
for i in range(1, n+1):
s += i
print(s)
Comments
Leave a comment