Program to find the sum of the first n natural numbers

# Sum of Natural Numbers
n = int(input("Enter a positive integer: "))
sum_n = n * (n + 1) // 2
print("Sum of the first", n, "natural numbers is:", sum_n)
Output:
Enter a positive integer: 10
Sum of the first 10 natural numbers is: 55

Leave a Reply

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