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

3 differences between mitosis and meiosis
a substance in a lab has the following characteristics: low density, compressible fluid, and random and fast-moving molecules. in which category would this subs
In the poem "In Flanders Field" who is the speaker?
What is the measure of angle y in this figure?HELP Enter your answer in the box. y = °
a block of wood is at rest on a wooden ramp
Is the scientific method able to be altered?
The _________ brings in the correct amino acid that is coded for in the mRNA. a . mRNA   b.  rRNA   c . tRNA
Dante uses symbols like the three beasts in the Divine Comedy so that he can _____. A.confuse the reader B.include spiritual themes C.avoid punishment for poli
Explain two ways that carbon returns to the atmosphere from animals.
11. Which was the biggest concentration camp? A. Westerbrok B. Auschwitz C. Buchenwald D. Flossenburg E. Hamburg