Write a Python Program to Find the Sum of Natural Numbers.

Write a Python Program to Find the Sum of Natural Numbers.

Natural numbers are a set of positive integers that are used to count and order objects. They are the numbers that typically start from 1 and continue indefinitely, including all the whole numbers greater than 0. In mathematical notation, the set of natural numbers is often denoted as "N" and can be expressed as:
𝑁 = 1,2,3,4,5,6,7,8,...
Program
def myfun():
    limit=int(input("Enter the limit: "))
    sum=0
    for i in range(1,limit+1):
        sum+=i
        
    print("The sum of natural numbers up to ",limit," is: ",sum)
        
if __name__=="__main__":
    myfun()



Output:

Enter the limit: 10
The sum of natural numbers up to 10 is: 55



More Questions


73 . Write a Python Program to Find the Sum of Natural Numbers.
74 . Write a Python Program to Find LCM.
75 . Write a Python Program to Find HCF.
76 . Write a Python Program to Convert Decimal to Binary, Octal and Hexadecimal.
77 . Write a Python Program To Find ASCII value of a character.
78 . Write a Python Program to Make a Simple Calculator with 4 basic mathematical operations.
79 . Write a Python Program to Display Fibonacci Sequence Using Recursion.
80 . Write a Python Program to Find Factorial of Number Using Recursion.
81 . Write a Python Program to calculate your Body Mass Index.
82 . Write a Python Program to calculate the natural logarithm of any number.
83 . Write a Python Program for cube sum of first n natural numbers?



For latest job updates join Telegram Channel: https://t.me/sateeshm