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

At Atwell middle school 60 percent of the 800 students participated in basket ball.How many students participated in basket ball
The primary focus of a persuasive speech
What's 20% as a decimal?
what are two theories archaeologists have explained as to why the ancient Harappans disappeared
Choose the sentence below in which of is used correctly. A. The three girls might of broken the records. B. We should of left early. C. The boys surrendered, b
the particles that make up a rock are constantly moving. however, a rock does not visibly vibrate. why is this?
Write an expression you could use to convert 2.5 gallons into quarts
how does kinetic energy affect the stopping distance of a small vehicle compared to a large vehicle
Draw quick pictures and write to tell how you would add 342 and 416
Three fourths of a number less two is five sixths of another number plus five