1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bad White [126]
3 years ago
9

Implement the sum_positive_numbers function, as a recursive function that returns the sum of all positive numbers between the nu

mber 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.
Computers and Technology
1 answer:
lakkis [162]3 years ago
5 0

Answer:

def sum_positive_numbers(n):

if(n==0 or n==1): #if n is 0 or 1 return n as its sum also will be n

return n

return n+sum_positive_numbers(n-1) #else return n and sum of all the number smaller then n

print(sum_positive_numbers(3)) # Should be 6

print(sum_positive_numbers(5)) # Should be 15

Explanation:

You might be interested in
Does any body like animal jam
cricket20 [7]

Answer:

Never used it so I do not know.

Explanation:

To be honest i thought you meant like animal jelly at first

7 0
4 years ago
Read 2 more answers
Katrina needs to send her database to colleagues, but she does not want them to access anything except the
tensa zangetsu [6.8K]

Answer: D

Explanation:

3 0
3 years ago
Your friend Aria is complaining that programming seems too complicated. She says, “Why do we need things like sequence, selectio
GaryK [48]

Answer: A sequence is a basic algorithm. A set of logical steps is carried out in order. A Selection and coding is the section of code that is only carried out if the conditions are met. A iteration is A line of code that is being repeated until the desired results has come out. A variable is a value that can change when the condition is changed your information passed through the program.

Explanation:

5 0
3 years ago
A program to add two numbers in C++
Paladinen [302]
I don't know if i understood correctly, but C++ can add numbers by using the + funciton. You could either use:
a = b + c
or
a = a + b
if you want to increment a variable.
7 0
4 years ago
What is the difference between operating systems and application software?
mojhsa [17]

Answer:

The main difference between operating system and application software is that an operating system is a system software that works as the interface between the user and the hardware while the application software is a program that performs a specific task.

Explanation:

5 0
3 years ago
Other questions:
  • Assume you have a sorting algorithm that you can use as a black box. Use the sorting algorithm to sort the input list. Now write
    10·1 answer
  • (2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you
    5·1 answer
  • Define the term Frame Rate.
    12·1 answer
  • which option of the AutoCorrect tool enables you to add and delete words that do not follow abbreviation rules?
    10·2 answers
  • Explain why implementing synchronization primitives by disabling interrupts is not appropriate in a single-processor system if t
    14·2 answers
  • Which category of system software provides a platform for application software to run on?
    12·2 answers
  • When using a search engine, what is the name of a word or phrase somebody types to find something online?
    12·2 answers
  • Use the function random.randint to write a program that rolls a 6-sided die 100 times, and prints out all of the rolls.
    8·1 answer
  • Need the answer ASAP!!! I’ll mark brainliest if correct
    5·1 answer
  • ANSWER ASAP! 50 POINTS!!!!
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!