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 : Built-in functions sum and range
Code Type : Function
Code Difficulty :
def sum_to_n(n):
return sum(range(1, n+1))