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

Chemistry help asap please :(
why should people in the northern hemisphere be concerned about rain forests in the southern hemisphere
if f(x) = |x| and g(x) = |x| − 4, which transformation is applied to f(x) to get g(x)? a vertical transformation of f(x) four units upward a horizontal transfor
who received greece and macedonia following alexander the great's death?
mis padres _____ muy simpáticos.
describe three symptoms of heart disease that should prompt an individual to seek emergency medical care.
Explain the importance of the grieving process after experiencing loss.
what happened before the united states could begin building a canal in panama?
La alfombra esta sucia. Debes
Which one of these items is a nonrenewable resource? a. plant b. tree c. gasoline d. fish