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 ruler of which Muslim empire created an enormous legal code for his empire? A.Ottoman Empire  B.Mughal Empire  C.Safavid Empire
What is the only trigonometric ratio that can have a value greater then 1?
Instead of going to school, what setting does pasty's prefer?
Give the final factored form of the expression. Provide an explanation AND identify the type of factoring used. x2 – 9y2 You don't have to identify the type of
[tex]2x+3=8 [/tex] identify any domain restrictions
Approximately how much of Central America’s agricultural land is used for cattle grazing?
PLEASE HELP ME THANKSS Solve |2x + 13| < 15.
A 20-inch board is to be cut into three pieces so that the second piece is 4 times as long as the first piece and the third piece is 5 times as long as the firs
what is the answer is 5p -8=1+ 5p -9
The initial population of a town is 127,866 and it grows with a doubling time of 13 years. What will the population be in 23 years?