Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions