answer.
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
Elanso [62]
2 years ago
9

7. Implement a function factorial in RISC-V that has a single integer parameter n and returns n!. A stub of this function can be

found in the file factorial.s. You will only need to add instructions under the factorial label, and the argument that is passed into the function is configured to be located at the label n. You may solve this problem using either recursion or iteration
Engineering
1 answer:
ohaa [14]2 years ago
3 0

Answer:

addi x31, x0, 4

addi x30, x0, 2

Explanation:

Recursion in computer sciencs is defined as a method of solving a problem in which the solution to the problem depends on solutions to smaller cases of the same problem. Such problems can generally be solved by iteration, but this needs to identify and index the smaller cases at time of programming.

addi x31, x0, 4

addi x30, x0, 2

addi x2, x0, 1600 // initialize the stack to 1600, x2= stackpointer

ecall x5, x0, 5 // read the input to x5

jal x1, rec_func

ecall x0, x10, 2 // print the result now

beq x0, x0, end

rec_func:

addi x2, x2, -8 // make room in stack

sd x1, 0(x2) // store pointer and result in stack

bge x5, x31, true // if i > 3, then go to true branch

ld x1, 0(x2)

addi x10, x0, 1 // if i <= 3, then return 1

addi x2, x2, 8 // reset stack point

jalr x0, 0(x1)

true:

addi x5, x5, -2 // compute i-2

jal x1, rec_func // call recursive func for i-2

ld x1, 0(x2) // load the return address

addi x2, x2, 8 // reset stack point

mul x10, x10, x30 // multiply by 2

addi x10, x10, 1 // add 1

jalr x0, 0(x1) // return

end:

You might be interested in
The 10-kg block slides down 2 m on the rough surface with kinetic friction coefficient μk = 0.2. What is the work done by the fr
Rashid [163]

Answer:

153.2 J

Explanation:

Let's first list our given parameters;

mass (m) of the block = 10 kg

which slides down ( i.e displacement) = 2 m

kinetic coefficient of friction (μk) = 0.2

In the diagram shown below;  if we take an integral look at the component of force in the direction of the displacement; we have

F_x= Fcos 40°

F_x= 100 (cos 40°)

F_x= 76.60 N

Workdone by the friction force can now be determined as:

W = F_x × displacement

W = 76.60 × 2

W = 153.2 J

∴  the work done by the friction force = 153.2 J

7 0
2 years ago
Problem 5) Water is pumped through a 60 m long, 0.3 m diameter pipe from a lower reservoir to a higher reservoir whose surface i
kap26 [50]

Answer:

\epsilon = 0.028*0.3 = 0.0084

Explanation:

\frac{P_1}{\rho} + \frac{v_1^2}{2g} +z_1 +h_p - h_l =\frac{P_2}{\rho} + \frac{v_2^2}{2g} +z_2

where P_1 = P_2 = 0

V1 AND V2  =0

Z1 =0

h_P = \frac{w_p}{\rho Q}

=\frac{40}{9.8*10^3*0.2} = 20.4 m

20.4 - (f [\frac{l}{d}] +kl) \frac{v_1^2}{2g} = 10

we know thaTV  =\frac{Q}{A}

V = \frac{0.2}{\pi \frac{0.3^2}{4}} =2.82 m/sec

20.4 - (f \frac{60}{0.3} +14.5) \frac{2.82^2}{2*9.81} = 10

f  = 0.0560

Re =\frac{\rho v D}{\mu}

Re =\frac{10^2*2.82*0.3}{1.12*10^{-3}} =7.53*10^5

fro Re = 7.53*10^5 and f = 0.0560

\frac{\epsilon}{D] = 0.028

\epsilon = 0.028*0.3 = 0.0084

4 0
2 years ago
Suppose we store a relation R (x,y) in a grid file. Both attributes have a range of values from 0 to 1000. The partitions of thi
leva [86]

Answer:

For (a) The total number of buckets from the given query for the relation is 25 buckets (b) the nearest neighboring query is (80, 200) (80, 150), (100, 150), (120,150) and (120, 200)

Explanation:

From the question stated, we need to define what a Grid file is

Grid File it is a structure of data that are used to divide the total space into a grid non-periodic, where set of point (small) are defined by more than one cells of the grid.

(a)Finding buckets for the query

The relation is divided into two parts which ranges from 0 to 1000, the first part is partitioned in every 20 units, at 20, 40, 60 etc; a second part is partitioned into every 50 units at 50, 100, 150 etc.

The total number of buckets from the given query for the relation is 25 buckets

(b)Finding the closest point or nearest point

The closest point discovered in the distance is little above 15

These points are are the points closer to the point target (110, 205) which can be found in five neighboring rectangles with left corners lower is stated as follows:

(80, 200) (80, 150), (100, 150), (120,150) and (120, 200)

3 0
2 years ago
A railcar with an overall mass of 78,000 kg traveling with a speed vi is approaching a barrier equipped with a bumper consisting
sergij07 [2.7K]

Answer:

v₀ = 2,562 m / s  = 9.2 km/h

Explanation:

To solve this problem let's use Newton's second law

              F = m a = m dv / dt = m dv / dx dx / dt = m dv / dx v

              F dx = m v dv

We replace and integrate

            -β ∫ x³ dx = m ∫ v dv

            β x⁴/ 4 = m v² / 2

We evaluate between the lower (initial) integration limits v = v₀, x = 0 and upper limit v = 0 x = x_max

        -β (0- x_max⁴) / 4 = ½ m (v₀²2 - 0)

         x_max⁴ = 2 m /β   v₀²

         

Let's look for the speed that the train can have for maximum compression

         x_max = 20 cm = 0.20 m

         

         v₀ =√(β/2m)   x_max²

Let's calculate

          v₀ = √(640 106/2 7.8 104)    0.20²

          v₀ = 64.05  0.04

          v₀ = 2,562 m / s

          v₀ = 2,562 m / s (1lm / 1000m) (3600s / 1h)

          v₀ = 9.2 km / h

5 0
2 years ago
What properties should the head of a carpenter’s hammer possess? How would you manufacture a hammer head?
BabaBlast [244]

Properties of Carpenter's hammer possess

Explanation:

1.The head of a carpenter's hammer should possess the impact resistance, so that the chips do not peel off the striking face while working.

2.The hammer head should also be very hard, so that it does not deform while driving or eradicate any nails in wood.

3.Carpenter's hammer is used to impact smaller areas of an object.It can drive nails in the wood,can crush  the rock and shape the metal.It is not suitable for heavy work.

How hammer head is manufactured :

1.Hammer head is produced by metal forging process.

2.In this process metal is heated and this molten metal is placed in the cavities said to be dies.

3.One die is fixed and another die is movable.Ram forces the two dies under the forces which gives the metal desired shape.

4.The third process is repeated for several times.

5 0
2 years ago
Other questions:
  • Mary is interested in developing new machines that would increase the productivity of small scale farmers. After high school, wh
    8·1 answer
  • A steady tensile load of 5.00kN is applied to a square bar, 12mm on a side and having a length of 1.65m. compute the stress in t
    13·1 answer
  • Air is compressed adiabatically from p1 1 bar, T1 300 K to p2 15 bar, v2 0.1227 m3 /kg. The air is then cooled at constant volum
    13·1 answer
  • Compute the strain-hardening exponent (n) for an alloy in which a true stress of 415 MPa produces a true strain of 0.10; assume
    10·1 answer
  • A piece of corroded metal alloy plate was found in a submerged ocean vessel. It was estimated that the original area of the plat
    6·1 answer
  • 4-6. A vertical cylindrical storage vessel is 10 m high and 2 m in diameter. The vessel contains liquid cyclohexane currently at
    10·1 answer
  • Define initial set and final set. Briefly discuss one method used to determine them. The following laboratory tests are performe
    12·1 answer
  • Madison and Oxford are the same distance from the equator and they are both near the ocean. Use the information on the map to an
    11·1 answer
  • Which requirement is an appropriate reason for a business to use information technology (IT) tools
    9·1 answer
  • Use the drop -down menus to select the appropriate question type. Picking between two possible alternatives: Showing an understa
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!