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

Which one is it A B C D ASAP please
what are ocean currents?
Heelp Balance the chemical reactions : Na2O + H2O ---> 2NaOH K2O + H2O ---> KOH MgO + H2O ---> Mg(OH)2 CaO + H2O ---> Ca(OH)2 SO2 + H2O ⇄ H2SO3 SO3
Why might a structural functionalist be concerned about high school dropout rates?
Why did the Schlieffen Plan ultimately collapse? Cite specific details from the text.
What is the appositive in this sentence: several students, ronnie, mark, and jack, ate lunch together?
I'm working on a project and I have to say how Cuban revolution affected the Cold War can I get some questions to answer them on my slides ?
Dan built a deck that is 5 feet long and 5feet wide . He built another deck that is 5 feet long and 7 feet wide . He built a thirt deck that is 5 feet long and
in an electric motor, periodically changing the electromagnet can cause the axle to spin because a. the electromagnet loses its magnetism b. mechanical energy
The most commonly reported form of abuse in the United States is _______.