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

Exercise 1. (Sum of Integers) Implement the functions sum_iter() and sum_rec() in sum_of_ints.py that take an integer n as argum

ent and return the sum S(n) = 1 + 2 + 3 + · · · + n, computed iteratively (using a loop) and recursively. The recurrence equation for the latter implementation is
Engineering
1 answer:
MatroZZZ [7]3 years ago
8 0

Answer:

Explanation:

We'll start out by prompting users to input an integer n. Then we create 2 functions to calculate the total, one by iteration and the other by recursion.

n = input('Please input an integer n')

def sum_iter(n):

    total = 0

    for i in range(n+1):

         total += i

    return total

sum_iter(n)

def sum_rec(n):

    if n == 0:

         return 0

    else:

         return n + sum_rec(n-1)

sum_rec(n)

You might be interested in
A nail that is rectangular in<br> cross section and has a blunt<br> point is called a
Travka [436]

Answer:

A nail that is rectangular in cross section and has a blunt point is called a Cut nail.

6 0
3 years ago
A gas cylinder system is composed of a cylinder fitted with a piston on which small weights are placed. Given that the initial p
Reika [66]

Answer:

the answer is going to be a I think

4 0
3 years ago
A technique for resolving complex repetitive waveforms into sine or cosine waves and a DC component is known as:
tatiyna

Answer:

(A) Fourier Analysis

Explanation:

Fourier Analysis  

It is the form of study of the way a general functions can be represented via the sum of the simple trigonometric functions .

It is named after Joseph Fourier , who represented a function as a sum of its trigonometric functions and it simplifies the study of the heat transfer .

Hence ,  

The technique for resolving the complex repetitive waveforms into the sine or the cosine waves and the DC component is known as the Fourier Analysis .

7 0
4 years ago
Help I will brainliest
ValentinkaMS [17]

Answer:

hacking?

Explanation:

jsd

3 0
3 years ago
Please read the short case at the end of Chapter 8, "Mary Barra of General Motors Values Culture". Use the following prompts to
Tom [10]

Answer: Incoherent question

Explanation: This is an act of plagiarism at subjecting the tutor to unnecessary stress at answering the purported question.

4 0
3 years ago
Other questions:
  • A cylindrical metal specimen having an original diameter of 11.53 mm and gauge length of 51.4 mm is pulled in tension until frac
    11·1 answer
  • Sketch the velocity profile for laminar and turbulent flow.
    15·1 answer
  • Generic Motors (GM) is making plans for its weekly operation for next year. GM makes three lines of
    13·1 answer
  • A specimen of a 4340 steel alloy with a plane strain fracture toughness of 54.8 MPa (50 ksi ) is exposed to a stress of 2023 MPa
    14·1 answer
  • Which type of material is known as elastomers to materials scientists and engineers
    14·1 answer
  • Who has good grades in school like A's B's dm me
    11·2 answers
  • Sorry here is my second one
    6·1 answer
  • Why is using the proper joining technique important? What could go wrong if the wrong joining technique is used?
    15·1 answer
  • How many spark plugs does a diesel have? How many glow plugs? If you are a redneck/country person dont answer...I wanna see how
    10·2 answers
  • Increase time to respond to threats through position and speed adjustments is risk management.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!