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
Do heavier cars really use more gasoline? Suppose a car is chosen at random. Let x be the weight of the car (in hundreds of poun
Alex17521 [72]

Answer:

Answer is explained in the explanation section below.

Explanation:

Solution:

Note: This question is incomplete and lacks necessary data to solve. But I have found the similar question on the internet. So, I will be using the data from that question to solve this question for the sack of concept and understanding.

Data Given:

x = 27 , 44 , 32 , 47, 23 , 40, 34, 52

y = 30, 19,  24,  13 , 29,  19,  21,  14

It is given that,

∑x = 299

∑y = 167

∑x^{2} = 11887

∑y^{2} = 3773

We are asked to verify the above values manually in this question.

So,

1. ∑x = 299

Let's verify it:

∑x = 27 + 44 + 32 + 47 + 23 + 40 + 34 + 52

∑x = 299

Yes, it is equal to the given value. Hence, verified.

2. ∑y = 167

Let's verify it:

∑y = 30 + 19 +  24 + 13 + 29 + 19 +  21 +  14

∑y = 169

No, it is not equal to the given value.

3. ∑x^{2} = 11887

Let's verify it:

For this to find,  first we need to square all the value of x individually and then add them together to verify.

∑x^{2} = 27^{2} + 44^{2} + 32^{2} + 47^{2} + 23^{2} + 40^{2} + 34^{2} + 52^{2}

∑x^{2} = 11,887

Yes, it is equal to the given value. Hence, verified.

4. ∑y^{2} = 3773

Let's verify it:

Again, for this we need to find the squares of all the y values and then add them together to verify it.

∑y^{2} = 30^{2} + 19^{2} +  24^{2} + 13^{2} + 29^{2} + 19^{2} +  21^{2} +  14^{2}

∑y^{2}  = 3,845

No, it is not equal to the given value.

4 0
3 years ago
A gas turbine receives a mixture having the following molar analysis: 10% CO2, 19% H2O, 71% N2 at 720 K, 0.35 MPa and a volumetr
Sliva [168]

Answer:

2074.2 KW

Explanation:

<u>Determine power developed at steady state </u>

First step : Determine mass flow rate  ( m )

m / Mmax = ( AV )₁ P₁ / RT₁   -------------------- ( 1 )

<em> where : ( AV )₁ = 8.2 kg/s,  P₁ = 0.35 * 10^6 N/m^2,   R = 8.314 N.M / kmol , </em>

<em>  T₁  = 720 K . </em>

insert values into equation 1

m  = 0.1871  kmol/s  ( mix )

Next : calculate power developed at steady state ( using ideal gas tables to get the h values of the gases )

W( power developed at steady state )

W = m [ Yco2 ( h1 - h2 )co2

Attached below is the remaining  part of the detailed solution

4 0
3 years ago
A college student volunteers with the elderly in a hospice program and discovers her clients complain of dry skin. She has an id
daser333 [38]

Answer:

D

Explanation: She hopes to be able to make this, however she hasn't yet...therefore she is thinking of a concept and it's development

3 0
3 years ago
Read 2 more answers
An excavation is at risk for cave-in and water accumulation because of the excess soil that has accumulated. What type of excava
N76 [4]

Answer:Topographic map. Contour line. Learning Objectives. After completing this chapter, you will be able to: □ Define civil engineering and civil drafting.

Explanation:

4 0
3 years ago
Read 2 more answers
ILL GIVE BRAINLIEST!!!
Sedbober [7]
Get the app socratic I saw the answer to your question on the app but I ran out of screen time to show you
6 0
2 years ago
Other questions:
  • What Type of diploma do you need in order To the get into JMU
    12·1 answer
  • Let suppose, you are going to develop a web-application for school management system. Then what architectural pattern will you u
    9·1 answer
  • Electrical pressure or “force”<br><br> A) current<br> B) resistance <br> C) voltage
    6·1 answer
  • 2- A 2-m3 insulated tank containing ammonia at -20 C, 80% quality, is connected by a valve to a line flowing ammonia at 2 MPa, 6
    14·1 answer
  • What's the best way to find the load capacity of a crane? Select the best option. Call the manufacturer Ask co-workers Look at t
    8·1 answer
  • A kernel-level thread wishes to acquire a mutex lock declared as global in the process. True or False: the function call used be
    6·1 answer
  • A barometer reads a height of 78 cmHg. Express this atmospheric pressure to:
    15·2 answers
  • Hi, can anyone draw me an isometric image of this shape?​
    7·2 answers
  • A 1/20 scale model of a wing is used to determine forces on the actual airplane. the 1/20 scale refers to the:_____
    10·2 answers
  • Lets Try This: study the pictures. Describe what you see and think about it. write your answer on a sheet of paper. home room
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!