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

"one has not only a legal but a moral responsibility to obey just laws. Conversely, one has a moral responsibility to disobey unjust laws." What principal is at
options most accurately show how the child speaker's story in "The Chimney Sweeper" (Songs of Experience) develops the tone of the poem? (Select all that apply.
What moment does Ferren say changed his life?
Help please with number 10,11,and 12
What does Senator Kaine argue is Congress's proper role in the war against ISIS?
simplify x+x^2+2x^2-3x
which of the following claims is thw best thesis statement for an analysis essay on romeo and juliet
Which point is an x-intercept of the quadratic function f(x) = (x – 4)(x + 2)?
Recall the first step in the process to determine theme. Summarize at least three events that happened in the fable. The Ants and the Grasshopper One fine day i
10.) state whether the given side lengths can form a triangle