Name: Anonymous 2022-09-22 9:36
Sup /prog/. I'm at my wits end. I cannot figure out how this recursive function in python works for the life of me. Will anyone help me out?
def calc_sum(n):
if n==1:
return 1
else:
return n+calc_sum(n-1)
print(calc_sum(3)) # prints 6??
def calc_sum(n):
if n==1:
return 1
else:
return n+calc_sum(n-1)
print(calc_sum(3)) # prints 6??