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

y=2x+7how do we solve this​
What is the slope of the number line?
An online clothing company sells custom sweatshirts. The company charges $6.50 for each sweatshirt and a flat fee of $3.99 for shipping. (a) Write a linear func
1. Which of these would be an example of an internal conflict? A. The main character has to deal with a bully. C. A main character is lost and has to find her B
what converts sunlight to chemical energy in a plant cell
Solve the quadratic equation 4x^2+3x-2=0
This text should be in three paragraphs. Select the words where the second and third paragraphs should begin A treatment for peanut allergies using peanuts them
How animals protect their young ones?
three (3) importance of unity in doing a school project
The role of technology in educating african child 750 words