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
Artemon [7]
3 years ago
9

Sum of Numbers Design a function that accepts an integer argument and returns the sum of all the integers from 1 up to the numbe

r passed as an argument. For example, if 50 is passed as an argument, the function will return the sum of 1, 2, 3, 4, . . . 50. Use recursion to calculate the sum. Demonstrate the function in a program.
Engineering
1 answer:
cestrela7 [59]3 years ago
4 0

Answer:

# define main to get an argument from the user, call the function, and display the final values

def main():

 # ask an argument from the user.

 number = int(input('Enter a positive integer: '))

 # solve the integral thing of the number by putting the user's argument in the addition() function

 finalSum = addition(number)

 # display the final value integral thing

 print("The integral of this number is ", finalSum, ".")

# define an addition function to find the integral

def addition(num):

 # make an if-statement to test filter things out of your calculations. In this case, 1.

 if num == 1:

   #if 1, return 1. because 1 + (1 - 1) = 1

   return 1

 # this is where the recursion actually is. This is the part that calculates

 else:

   return num + addition(num-1)

# call your main function

main()

Explanation:

This is written in Python. A link to the output can be found below.

https://Sum-of-Numbers.hufflepuffler07.repl.run

You might be interested in
Technician A ay that acid rain doe the mot harm when it firt fall on a finih. Technician B ay that hard water potting i uually j
Tamiku [17]

Technician B is right say that hard water potting i usually jut a Surface problem that can be wahed off.

What do you mean by Hard water?

The amount of dissolved calcium and magnesium in the water determines its hardness. Calcium and magnesium are the main dissolved minerals in hard water. The last time you washed your hands, you might have actually felt the effects of hard water.

What do you mean by acid rain?

Any type of precipitation that contains acidic elements, such as sulfuric or nitric acid, that falls to the ground from the atmosphere in wet or dry forms is referred to as acid rain, also known as acid deposition. Rain, snow, fog, hail, and even acidic dust can fall under this category.

Some plants are sensitive to excessive moisture around their root zone, so it may be necessary to increase drainage when growing plants in pots. Additionally, standing water at the bottom of the pot can cause root rot.

Many university agriculture extension agencies have thoroughly debunked the old garden myth that adding rocks to the bottom of a pot will increase drainage.

Learn more about hard water click here:

brainly.com/question/28178305

#SPJ4

6 0
1 year ago
Ughhh I feel so moody rn and I’m cramping so bad
padilas [110]
Explanation:!!

I hope you Feel better :)
3 0
3 years ago
Read 2 more answers
Three-dimensional measuring references all of these EXCEPT:
cricket20 [7]
Except the Table of Contents
4 0
3 years ago
Only respond if your the person im talkin to
bagirrra123 [75]

Answer: um wuh anyways thxs for the points!

Explanation: ....:/

5 0
3 years ago
You can change lanes during a turn long as there’s no traffic and you driving slowly
Vanyuwa [196]
Your allowed to switch lanes as long as the road is clear and you use signals.
5 0
3 years ago
Other questions:
  • Students are expected to respond to one of the two questions described below. Students should provide examples to clarify their
    12·1 answer
  • Please Help It's really Important
    12·1 answer
  • suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign
    11·1 answer
  • Water is flowing in a metal pipe. The pipe OD (outside diameter) is 61 cm. The pipe length is 120 m. The pipe wall thickness is
    9·1 answer
  • What is the angular velocity (in rad/s) of a body rotating at N r.p.m.?
    13·1 answer
  • Demonstreaza in 20 de propoziti ca snoava pacala si zarzarele boerului e o snoava
    12·1 answer
  • Tony works as a Sorter in a processing factory. Which qualifications does he most likely have?
    10·2 answers
  • The Hubble Space Telescope is an optical imaging telescope with extremely good angular resolution. Someone discovers an object t
    13·1 answer
  • The variation of the pressure of a fluid with density at constant temperature is known as the _____.
    5·1 answer
  • At the beginning of last year, tarind corporation budgeted $1,000,000 of fixed manufacturing overhead and chose a denominator le
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!