diff --git a/Python/PythonBasics/SumOfNaturalNumbers.py b/Python/PythonBasics/SumOfNaturalNumbers.py new file mode 100644 index 0000000..89e8da7 --- /dev/null +++ b/Python/PythonBasics/SumOfNaturalNumbers.py @@ -0,0 +1,5 @@ +# Calculates the sum of the first n natural numbers + +n = int(input("Enter a natural number: ")) +sumN = (n * (n + 1)) // 2 +print("Sum of the first ", n, "natural numbers: ", sumN) \ No newline at end of file