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

Let z = 17.   What is the value of 51 – z?
As food passes through the alimentary canal, the presence of chemical secretions will occur in which order?   a. Salivary enzymes; pancreatic juice; pepsin b.
The triangles shown below must be congruent. True or false
Help with a history question. Will fan and medal, Thank you :) Reporter McQuill mentions your claim will be stronger if you respond well to someone who disagree
A particular compound has a stronger hydrogen bonds than water. A student states that the substance probably has a higher specific heat than water. Do you agree
how do you convert 3 meters to centimeters?
Please help with math!! Will mark and star!!! ☯ ♥ ✌
Which is a hormone secreted by the pancreas
Name the four functions of the cardiovascular system
what events led to the frontier wars?