Write a program that asks the user for a positive integer value. The program should calculate the sum of all the integers from 1 up to the number entered.
For example, if the user enters 20, the loop will find the sum of 1, 2, 3, 4, ... 20.

Source Code

n = int(input("Enter a positive integer: "))
sum = 0

for i in range(1, n+1):
    sum += i

print("Sum of natural numbers up to", n, "is", sum)

Output

Enter a positive integer: 20
Sum of natural numbers up to 20 is 210