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

You can easily separate a solution of sugar water through filtration. True False
List frog, bat, lobe-finned fish, and alligator in order of their relationship to humans. Start with the species most closely related to humans.
the westside bakery uses 440 pounds of sugar to make 1,000 cakes each cake contain the same amount of sugar how many pounds of sugar are used in each cake
Help please =) What is the slope of the line –6y + 2x = 18 in simplest form?
what is an equation that relates weight on earth to weight on the moon
How did Puritan values of the seventeenth century influence Americans of the nineteenth century? A. Americans embraced the Puritan idea of religious toleratio
how can you estimate 642 fl oz in cups
Which statement about President Kennedy is true? A. He visited the divided city of Berlin and gave a powerful speech about political freedom. B. He only appoint
Explain the differences in the vocabulary words given below. Then explain how the words are related. Use completed sentences in your answer. 1. fossil fuel- pe
What is 43.78 in word form