Computer Science, asked by AmyphaaChangmai, 6 days ago

Write a program to accept a number from a user and calculate the sum of all numbers from 1 to a given number

Expected Output:
Enter a value: 5
Sum of all values: 15

Answers

Answered by adityaray38970
0

Answer:

n = int(input("Enter number"))

sum = 0

for num in range(1, n + 1, 1):

sum = sum + num

print("Sum of numbers is: ", sum)

Similar questions