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

Question 3 of 10 3 Points When Ron and Shelly disagree about the most effective method for measuring a patient's temperature, they decide to try each other's me
What is the measure of angle b ?!
Use your knowledge of plate tectonics to explain why the supercontinent of Pangaea could have existed long ago. How did Pangaea break apart, and how were our co
Line I and h intersect at what point
During the high Middle Ages in Europe, thousands of trees were cleared to make way for A.towns B.crops C.roads D.castles
What is a reasonable estimate for the limit of hhh at x=3x=3x, equals, 3?
Writers should check to make sure their homophones are used accurately because homophones are easily confused due to their similar Abc sounds histories meanings
In what year were the first ever Olympic Games held
A line that passes through [-7,3] and [-6,-1]
Which term accurately describes the following statement