Question: Please use PYTHON3, knowledge of recursion to answer the question. [2 points] Computing a sum recursively. Recall that n! (n factorial) is defined as follows

Please use PYTHON3, knowledge of recursion to answer the question.

[2 points] Computing a sum recursively. Recall that n! (n factorial) is defined as follows n! = n x (n-1) (n-2) x x 2 x 1, for n > 0 and 0-1 The following recursive function computes the factorial of n, assuming n 20: def factorial(n): 1. return 1 else: return n * factorial(n-l) Page 1 In the file sum.py, write a recursive function sum_positive (n) for n 20 that computes the sum S of the first n positive integers: S-n(n-1) +... 21 for n>0 If n = 0, then the sum is 0 by definition. Your function must be recursive. It should not use a loop nor use lists. Hint: Your function will look very similar to the factorial function above! Example usage: >python3 -i sum.py >sum positive(1) 1 >sum _positive(5) 15 @Mao102335422

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!