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

XY has endpoints at -13 and 23. What is the coordinate of its midpoint
What was a difference between immigrants who arrived in the united states during the 1840's and the 1850's and the 'new' immigrants who began arriving in the 18
What were three eventual consequences of william the conqueror's victory at hastings?
Why was columbus more confident than others about his ability to sail westward?
what is the best definition for the term interest rate?
In which direction does a reverse fault cause the land to move? up down left right
True or false? one basic strategy that helps us organize our exploration of a set of data is to begin by examining each variable by itself. then move on to stud
Which expression results when the change of base formula is applied to log4(x+2) ?
El producto de 4 y un numero, aumentado en 17 es 221. Cual es el numero?
Is helium a homogeneous or heterogeneous mixture or compound or element?