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

Identify the unit rate in the graph. A) 125 B) 75 C) 50 D) 25
Suppose two rectangles are similar with a scale factor of 2. What is the ratio of their areas? Explain
Subtract 16a+3 from 13a−5 . Which is the correct answer? −16a−2 16a−2 16a−8 −16a+8
What are three ways the American workforce has changed recently?
After everything we've been through of after all we've been through?
Solve the quadratic equation by completing the square. x^2+18x+76=0 First, choose the appropriate form and fill in the blanks with the correct numbers. Then,
Contact between a phage and its bacterial host occurs by _____.
Read the following excerpt from The Great Gatsby: I supposed he'd had the name ready for a long time, even then. His parents were shiftless and unsuccessful fa
A single carbon atom can form a maximum of how many covalent bonds
What form of government is a republic? Roman A polis city-state Polytheistic Representative