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
Write a Bare Bones program that takes as input a value for X and places 4 times the value of X into the value of Z. The value of
Vlada [557]

Answer:

See the code snippet in the explanation section

Explanation:

import java.util.Scanner;

public class BareBonesProgram{

public static void main (String[] args){

 Scanner scan = new Scanner(System.in);

 System.out.println("Please enter the value of x: ");

 int x = scan.nextInt();

 int z = 4 * x;

 System.out.println("The value of z is: " + z);

 System.out.println("The value of x is: " + x);

}

}

6 0
3 years ago
While Angela is making modifications to Katie’s Word document, she would like to inform Katie of the reasoning for the change. W
Ostrovityanka [42]

Answer:

Email would work

6 0
4 years ago
An attribute that can have more than one value for each entity instance is referred to as:
ss7ja [257]

Answer:

D) a multivalued attribute

Explanation:

A multivalued attribute  can have more than one value associated with the entity key.

6 0
3 years ago
A technician is tasked with installing the Windows OS on a Mac OS computer so that the computer can boot to either the Mac OS or
nata0808 [166]

Answer:

Key chain because it easier

Explanation:

4 0
2 years ago
What are the inputs and outputs of the app "Spotify"?
Anastasy [175]

Hey the I/O for Spotify would be. for I or input keyboard and mouse.

and for O or output the sound files being sent from the server to the pc

Hope this helps.

-Toby  aka scav

6 0
3 years ago
Other questions:
  • Suggest how the following requirements might be rewritten in a quantitative way. You may use any metrics you like to express the
    7·1 answer
  • A technician is troubleshooting a Windows system in which an application works properly when the computer is booted in Safe Mode
    14·1 answer
  • In which architecture is the application logic usually on the client side?
    8·1 answer
  • Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the
    14·1 answer
  • Which of the following is a scam where perpetrators promise high pay for working on different projects like wooden calendars, pa
    13·1 answer
  • On net, is technology good or bad for society? Please explain, support your argument, I’ll mark brainliest
    9·2 answers
  • What manages and control the speed of a motherboards buses
    5·1 answer
  • Which of the following identifies the most appropriate courses to take in high school for someone interested in becoming a mecha
    9·1 answer
  • Explain why people struggle to control themselves when they engage with social media
    15·2 answers
  • Write the text of the program in Python.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!