Question: HI, I have this problem : Implement the sum_positive_numbers function, as a recursive function that returns the sum of all positive numbers between the number

HI, I have this problem :

Implement the sum_positive_numbers function, as a recursive function that returns the sum of all positive numbers between the number n received and 1. For example, when n is 3 it should return 1+2+3=6, and when n is 5 it should return 1+2+3+4+5=15.

The code :

def sum_positive_numbers(n): return 0

print(sum_positive_numbers(3)) # Should be 6 print(sum_positive_numbers(5)) # Should be 15

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!