Python Program to Find the Sum of Natural Numbers

Spread the love

In this article, You will learn about python program to find the sum of natural numbers

Formula:

n*(n+1)/2

Program:

n=16 sum = n*(n+1)/2 print("sum of natural numbers",sum)

Output:

sum of natural numbers 136.0
By using dynamic variables:
n=int(input("enter value")) sum = n*(n+1)/2 print("sum of natural numbers",sum)

Output:

enter value20
sum of natural numbers 210.0
admin

admin

Leave a Reply

Your email address will not be published. Required fields are marked *