frozengirl309 frozengirl309
  • 03-07-2019
  • Computers and Technology
contestada

Give a recursive (or non-recursive) algorithm to compute the product of two positive integers, m and n, using only addition and subtraction ?

Respuesta :

SerenaBochenek SerenaBochenek
  • 14-07-2019

Answer:

Multiply(m,n)

1. Initialize product=0.

2. for i=1 to n

3.      product = product +m.

4. Output product.

Explanation:

Here we take the variable "product" to store the result m×n. And in this algorithm we find m×n by adding m, n times.

Answer Link

Otras preguntas

The plans for a shed call for a rectangular floor with a perimeter of 204 ft. The length is two times the width. Find the length and width.
The length of a pool is 3 feet more than twice its width. If the perimeter of the pool is 72 feet, find the dimensions of the pool by writing and solving a syst
Al washed a car in 6 minutes. Fred washes the same car in 8 min. How long dies it take Al and Fred to wash the car together?
Where do the cranial nerves originate? Where do the spinal nerves originate?
Which word is an interjection commonly used in advertising?
If 2 less than or equal too X less than or equal too 6, which of the following has the greatest value
What is the coefficient of y in the expression 12+3y-2x?
The formula C = 20x + 5 models the cost of New York Yankees T-shirts, where C is the cost and x is the number of shirts sold. Choose ALL TRUE statements in the
How consumers behaviour affect market equilibrium
(X+12) 2 ÷ x2-144 ×-12. 12×-144