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

A graphic designer usually intends to please one individual patron. a. True b. False
Help would be appreciated!
Read the sentence. The student whom Mr. Stein chose was first in her class. Bolded words are "whom Mr.Stein chose"
What agreement by the united states, japan, great britain, and france in 1921 promised that each nation would respect each other's possessions in the pacific an
How did women of the progressive era make progress and win the right to vote?
When dose beah flash back to the last time he saw his parents
28 divided by 7 + 2 x 3 =
Match the form of the verb with the sentence. Mon oncle _____ cinq enfants. Nous ______ sept euros. Mes cousins n’ ____ pas faim. J’ ______ sommeil. A)
MyPyramid is based on a _____-Calorie diet. A. 1,200 B. 2,000 C. 2,500 D. 1,600
You have 7 balls that are each a different color of the rainbow. In how many distinct ways can these balls be ordered?