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
Lorico [155]
3 years ago
15

The way most recursive functions are written, they seem to be circular at first glance, defining the solution of a problem in te

rms of the problem itself ("A rose is a rose is a rose"). For example, a recursive function to compute the factorial of n might look like this:
Engineering
1 answer:
EastWind [94]3 years ago
6 0

Question Continuation

int factorial(int n) {

if(n == 0)

return 1;

else

return n * factorial(n - 1);

}

Provide a brief explanation why this recursive function works.

Show all steps involved in calculating factorial(3) using the function defined.

Answer:

1. Brief explanation why this recursive function works.

First, the recursive method factorial is defined.

This is the means through with the machine identifies the method.

The method is defined as integer, the machine will regard it as integer.

When the factorial is called from anywhere that has access to it, which in this case is within the factorial class itself. This means you can call it from the main method, or you can call it from the factorial method itself. It's just a function call that, well, happens to call itself.

2. Steps to calculate factorial(3)

1 First, 3 is assigned to n.

2. At line 2, the machine checks if n equals 0

3. If yes, the machine prints 1

4. Else; it does the following from bottom to top

factorial(3):

return 3*factorial(2);

return 2*factorial(1):

return 1;

Which gives 3 * 2 * 1 = 6

5. Then it prints 6, which is the result of 3!

You might be interested in
It is not a practical proposition to take direct measurements in nanoscale, but we can estimate variations in position and momen
Volgvan

Answer:

Answer is c Heisenberg's uncertainty principle

Explanation:

According to Heisenberg's uncertainty principle there is always an inherent uncertainty in measuring the position and momentum of a particle simultaneously.

Mathematically

\Delta x\times \Delta \overrightarrow{p}\geq \frac{h}{4\pi }

here 'h' is planck's constant

7 0
3 years ago
Tanya Pierce, President and owner of Florida Now Real Estate is seeking your assistance in designing a database for her business
const2013 [10]

Answer:

the answer is attributes for each entity

5 0
3 years ago
Which best describes the body in terms of simple machines?
alex41 [277]

Answer:B

Explanation:

5 0
3 years ago
Three capillary tubes with different radius (r1=1.0mm, r2=0.1mm, r3=0.01mm) are inserted into the same cup of water. The surface
kobusy [5.1K]

Answer:

you fgykyiihohuoououu

Explanation:

jjj

4 0
3 years ago
15 POINTS! Help.
IRISSAK [1]

Answer: it would  overload

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is EL Niño?
    9·1 answer
  • A power of 100 kW (105 W) is delivered to the other side of a city by a pair of power lines, between which the voltage is 12,000
    9·1 answer
  • Historically, the introduction of technology has caused profound changes in the labor market and, temporarily at least, displace
    6·1 answer
  • Mobility refers to the ability to?
    12·1 answer
  • Different Gauss quadrature formulae predict different values for the same integral a. True b. False
    11·1 answer
  • A civil engineer is likely to fit in which of the Holland occupational codes?
    14·2 answers
  • 30POINTS
    15·2 answers
  • You may have to_______
    14·1 answer
  • Alguém para conversa
    13·1 answer
  • Help please i will give brainlist
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!