Title: Sum of the even numbers up to the specified
number
Sum of the up to 10 even numbers is
2+4+6+8+10=30
Program:
n=int(input("Enter n value\n"))
sum=0
for i in range(2,n+1,2):
sum=sum+i
print("Sum of upto ",n," even numbers is",sum)
Output:
Enter n value
10
Sum of upto
10 even numbers is 30
Comments
Post a Comment