# 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
# 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
+91-8400061384
support@ithunt.org