Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started