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
Sea water with a density of 1025 kg/m3 flows steadily through a pump at 0.21 m3 /s. The pump inlet is 0.25 m in diameter. At the
myrzilka [38]

Answer:

\dot W_{pump} = 16264.922\,W\,(16.265\,kW)

Explanation:

The pump is modelled after applying Principle of Energy Conservation, whose form is:

\frac{P_{1}}{\rho\cdot g}+ \frac{v_{1}^{2}}{2\cdot g} +z_{1} + h_{pump}=\frac{P_{2}}{\rho\cdot g}+ \frac{v_{2}^{2}}{2\cdot g} +z_{2}

The head associated with the pump is cleared:

h_{pump} = \frac{P_{2}-P_{1}}{\rho\cdot g}+\frac{v_{2}^{2}-v_{1}^{2}}{2\cdot g}+(z_{2}-z_{1})

Inlet and outlet velocities are found:

v_{1} = \frac{0.21\,\frac{m^{3}}{s} }{\frac{\pi}{4}\cdot (0.25\,m)^{2} }

v_{1} \approx 4.278\,\frac{m}{s}

v_{2} = \frac{0.21\,\frac{m^{3}}{s} }{\frac{\pi}{4}\cdot (0.152\,m)^{2} }

v_{2} \approx 11.573\,\frac{m}{s}

Now, the head associated with the pump is finally computed:

h_{pump} = \frac{175\,kPa-81.326\,kPa}{(1025\,\frac{kg}{m^{3}} )\cdot (9.807\,\frac{m}{s^{2}} )} +\frac{(11.573\,\frac{m}{s} )^{2}-(4.278\,\frac{m}{s} )^{2}}{2\cdot (9.807\,\frac{m}{s^{2}} )} + 1.8\,m

h_{pump} = 7.705\,m

The power that pump adds to the fluid is:

\dot W_{pump} = \dot V \cdot \rho \cdot g \cdot h_{pump}

\dot W_{pump} = (0.21\,m^{3})\cdot (1025\,\frac{kg}{m^{3}})\cdot (9.807\,\frac{m}{s^{2}})\cdot(7.705\,m)

\dot W_{pump} = 16264.922\,W\,(16.265\,kW)

4 0
3 years ago
O que é necessário se conhecer para a determinação de uma força concentrada em um ponto?
skelet666 [1.2K]

Answer: its c

Explanation:

7 0
3 years ago
Required information NOTE: This is a multi-part question. Once an answer is submitted, you will be unable to return to this part
ra1l [238]

Answer:

h1 = 290.16kj/kg

P = 1.2311

Prandil expression at 8

P=p1/p7×pr

=8(1.2311)

=9.85

Enthalpy state at 8 corresponding to 9.85

h1 = 526.13kj/kg

Now prandtl state at 9 that correspond to 1400k.

h9 = 1515.42kj/kg

Pr = 450.5

Prandtl expression at state 10

P= p10/p9×pr

=1/8(450.5)

=56.31

Enthalpy at state 10 corresponding to prandtl 56.31

h10 = 860.39kj/kg

At 520k

h11 = 523.63kj/kg

4 0
3 years ago
When entering a freeway you should always:
marissa [1.9K]
B. watch your surroundings
6 0
4 years ago
Read 2 more answers
What engineers call moment, scientists call
Svet_ta [14]

Answer:

yes

Explanation:

7 0
3 years ago
Other questions:
  • Please read
    6·1 answer
  • Consider a resistor made of pure silicon with a cross-sectional area pf 0.5 μm2, and a length of 50 μm. What is the resistance o
    6·1 answer
  • a triangle is defined by the three vertices. write the following functions of the triangle class assume that the point class has
    7·1 answer
  • The load on a bolt consists of an axial pull of 10 KN together with a transverse shear force of 5 KN. Find the diameter of bolt
    11·1 answer
  • HELP PLEASE!!!!
    12·1 answer
  • A two-bus power system is interconnected by one transmission line. Bus 1 is a generator bus with specified terminal voltage magn
    6·1 answer
  • Please LIKE & SHARE to keep our generators available!
    15·2 answers
  • Stirrups are used in a concrete beam:_______
    5·1 answer
  • All of these are true about steel EXCEPT that:
    7·1 answer
  • ceramics must be heated in order to harden the clay and make it durable. the equipment used to heat the clay
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!