Write Method Multiply Multiplies Two Integer Parameters Returns Integer Result May Assume Q37181665

Write a method multiply that multiplies two integer parametersand returns the integer result. You may assume that the parametersare positive (greater than zero). You may not use themultiplication operator * or loops (for, while, etc); youmust use recursion and addition. Recall theidentity a*b = b + (a-1)*b and 1*b = b. (JAVA)


Answer


public static int mul(int a, int b){ if(b == 0 || a == 0){ return 0; } else if(a == 1){ return b;

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.