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
The uniform slender rod has a mass m.
Nikolay [14]

Answer: 3/2mg

Explanation:

Express the moment equation about point B

MB = (M K)B

-mg cosθ (L/6) = m[α(L/6)](L/6) – (1/12mL^2 )α

α = 3g/2L cosθ

express the force equation along n and t axes.

Ft = m (aG)t

mg cosθ – Bt = m [(3g/2L cos) (L/6)]

Bt = ¾ mg cosθ

Fn = m (aG)n

Bn -mgsinθ = m[ω^2 (L/6)]

Bn =1/6 mω^2 L + mgsinθ

Calculate the angular velocity of the rod

ω = √(3g/L sinθ)

when θ = 90°, calculate the values of Bt and Bn

Bt =3/4 mg cos90°

= 0

Bn =1/6m (3g/L)(L) + mg sin (9o°)

= 3/2mg

Hence, the reactive force at A is,

FA = √(02 +(3/2mg)^2

= 3/2 mg

The magnitude of the reactive force exerted on it by pin B when θ = 90° is 3/2mg

6 0
3 years ago
You will be hiking to a lake with some of your friends by following the trails indicated on a map at the trailhead. The map says
bulgar [2K]
<h2>Answer: <u><em>64.58</em></u></h2>



Explanation:

3 0
2 years ago
Why are Gas cars Bad?(cons) pls help me its part of project thx<br>:) thx if u do help​
o-na [289]

Answer:

  • Depletes Fossil Fuels
  • Polution

Explanation:

Fossil Fuels take millions of years to be made. Gasoline is made up of primarily petroleum (a fossil fuel) which is easily refined into gasoline or kerosene. This means that once you run out of a fossil fuel...you're out of it.

Gas cars are also very big polutants. If you've ever heard of an emmisions test for a car, it is a test that sees how much pollution a car puts out into the air. It meassures how safe those levels are. This is a big indicator of how much cars pollute becasue there is a need to test your car every year. The gases that can be put into the air are harmful not only to humans and animals but to the climate and atmosphere.

5 0
3 years ago
F both wires in the twisted pair CANbus need to be repaired, it is best to:
Ne4ueva [31]

Answer:

sorry I couldn't help you

3 0
2 years ago
Why do engineers play a variety of roles in the engineering process? They are part of a team. They need to act as both scientist
Kamila [148]

Answer: They showed that many people worked on the project and demonstrate how hard they worked.

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • The difference between ideal voltage source and the ideal current source​
    7·2 answers
  • The hot and cold inlet temperatures to a concentric tube heat exchanger are Th,i = 200°C, Tc,i = 100°C, respectively. The outlet
    10·1 answer
  • A metallic material with yield stress of 140 MPa and cross section of 300 mm x 100 mm, is subjected to a tensile force of 8.00 M
    12·1 answer
  • The viscosity of the water was 2.3×10^−5lb⋅⋅s/ft^2 and the water density was 1.94 slugs/ft^3. Estimate the drag on an 88-ft diam
    13·1 answer
  • What is the net force acting on a car cruising at a constant velocity of 70 km/h (a) on a level road and (b) on an uphill road?
    11·1 answer
  • How does refrigeration preserve food and dead bodies​
    12·2 answers
  • Q1. Basic calculation of the First law (2’) (a) Suppose that 150 kJ of work are used to compress a spring, and that 25 kJ of hea
    6·1 answer
  • (25) Consider the mechanical system below. Obtain the steady-state outputs x_1 (t) and x_2 (t) when the input p(t) is the sinuso
    9·1 answer
  • True or False; If I was trying to find the Voltage of my computer, and I was given the Watts and Amps it uses, I would use Watt'
    8·1 answer
  • (Blank) welding involves manual welding with equipment anomalously controls one or more of the windy conditions while (blank) we
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!