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

Any ideas for a science fair project involving anything with anime, anime art, baking, desserts, something about cuteness, or anything else that might be good!
The condition of earth's atmosphere at a certain time and place
Modernist works could best be described as:.
What are the layers of the earth and what are they made out of?
All the Values of X in a table are greater than the corresponding values of y. If x is a positive integer what operation(s) and circumstance(s) could explain th
Ask Elena if she is interested in learning how to knit.
Political campaigns use technology such as the internet, blogs, television, radio and cell phones to distribute their message. True or false
how did Czar Alexander II's emancipation edict affect the lives of Russian serfs?
Find the appositives in the sentence: Ralph, my pet tarantula, lives in my room.
All of the following are true about Homer except a. He was a deaf poet. c. He is credited with being the first to put the Epics into writing. b. He wrote the Od