Python program to print sum of n natural numbers

Views: 107   

Following program shows you how to print sum of n natural numbers.
In this program we get number from user and shows sum of n natural numbers using following formula
Sum of n natural numbers = input X (input + 1)/2

number = float(input("Enter a number:"))
result = number * (number + 1) / 2
print(result)

Output:

Enter a number: 35
630.0
On By