# file: InClassAssignment1.py
# Here are the definitions for the following two functions presented:
# sumN(n) returns the sum of the first n natural numbers
# sumNSquares(n) returns the sum of squares of the first n natural numbers
#
def sumN(n):
sum_=0 # initially sum is 0
for i in range(1,n+1): # sequence [1,2,...,n] is generated, i iterates over it
sum_ += i # i is added to the sum at each iteration
return sum_
def sumNSquares(n):
sum_=0 # initially sum of squares is 0
for i in range(1,n+1): # sequence [1,2,...,n] is generated, i iterates over it
sum_ += i*i # i^2 is added to the sum at each iteration
return sum_