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

In the five forces model, the __________ that companies compete against one another for customers, the _________ the level of profits is likely to be for that i
How did the great depression affect arizona in comparison to the rest of the united states?
Of the approximately 27.3 million small businesses in this country, ____ have no employees.
Write a word problem whose solution is |-70| = 70
In the human body, all body systems work to maintain homeostasis. One system stands out as a leader, as it works with all other body systems. That is the ______
Why are primers needed for dna replication?
When information in memory is rehearsed and stored on a relatively permanent basis, it is called short-term memory. sequential memory. sensory memory. long-term
Can you help me please?
How did Great Britain attempt to sway the United States to support the Allies during World War 1?
The difference of a number times 4 and 9 equals 5