Python Program to find Sum of Even Numbers

n=int(input("Enter n value:"))
sum=0
for i in range(2,n+1,2):
    sum+=i
print(sum)

OUTPUT:

Enter n value:5
6

Leave a Comment