Answer:
Step-by-step explanation:
We'll start out by prompting users to input an integer n. Then we create 2 functions to calculate the total, one by iteration and the other by recursion.
n = input('Please input an integer n')
def sum_iter(n):
total = 0
for i in range(n+1):
total += i
return total
sum_iter(n)
def sum_rec(n):
if n == 0:
return 0
else:
return n + sum_rec(n-1)
sum_rec(n)