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

Virus and bacteria worksheet
a liner function of x is graphed on a coordinate grid. the points 6,34 and 18,26 lie on the graph of the function what are the rate of change of the function an
please help me find which expression it is !!!
Which of the following ways to avoid excavation hazards was mentioned in the Construction eTool? (Check all that apply) Pile soil close to the excavation site.
Describe the process of trying to get the ERA ratified in 3-5 bulletins.​
“How fast do X rays travel in a vacuum?
2/5 times 8/15 didided by 1/4
Write the equation of the line that has a slope of - 2/3 and a y-intercept of (0,-7)
I need help with this question ASAP
Scott invested his savings in two investment funds. The $4000 that he invested in Fund A returned a 2% profit. The amount that he invested in Fund B returned a