Question: Which line handles the recursive case for this function that calculates the sum of the first n natural numbers? def nsum ( n ) :

Which line handles the recursive case for this function that calculates the sum of the first n natural numbers?
def nsum(n):
if n ==0:
sum =0
elif n ==1:
sum =1
else:
sum = n + nsum(n-1)
return sum
a.
sum =1
b.
return sum
c.
if n ==0
d.
sum = n + nsum(n-1)
e.
elif n ==1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!