You can download this code by clicking the button below.
This code is now available for download.
Calculates the sum of natural numbers from 1 to n
Technology Stack : None
Code Type : Mathematical calculation function
Code Difficulty :
def sum_to_n(n):
total = 0
for i in range(1, n+1):
total += i
return total