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

How did president frankin d roosevelt increase the power of the presidency
In Egyptian culture,what role did temples most likely play in everyday religious practice and community life?
Which of the following statements correctly describes the effect a nonsense mutation would have on a gene?a) It changes an amino acid in the encoded protein.b)
Please help need answer please
I have to write about the theme of the book “wonder”
Incredible is too believable as disinterest it is to
What is the BEST title for this list? A) "Allies During World War II" B) "Enemies During World War II" C) "Countries Attacked by Japan" D) "Countries Invaded
Which best decribes the Cold War? A) A lessening of tensions between U.S. and Soviet Union begun to insure a lasting peace between superpowers. B) Any struggl
For a conclusion to be accepted by the scientific community, the data must be accurate, free from error, and reproducible. varied. unique. surprising.
Every sentence must have a blank and a blank