Without using a division or multiplication operator and without using iteration, define a recursive method named named product that accepts two int parameter, m and k, and calculates and returns the product of m times k. You can count on m>=0 and k>=0.

LANGUAGE: JAVA

CHALLENGE:

Without using a division or multiplication operator and without using iteration, define a recursive method named named product that accepts two int parameter, m and k, and calculates and returns the product of m times k. You can count on m>=0 and k>=0.

SOLUTION:

public int product(int m, int k) {
if (k == 0){
return 0;
}
if (k == 1){
return m;
}else if (k == 2){
return (m + m);
}else{
return (product(m, k-1) + m);
}
}