118k views
2 votes
Give a recursive (or non-recursive) algorithm to compute the product of two positive integers, m and n, using only addition and subtraction ?

User Arleen
by
4.8k points

1 Answer

4 votes

Answer:

Multiply(m,n)

1. Initialize product=0.

2. for i=1 to n

3. product = product +m.

4. Output product.

Step-by-step 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.

User Blablabla
by
5.0k points