We exploit the following recursive definition of the product between two non-negative integers:
Implementation (we assume that the method sum() is defined in the same class):
public static int product(int x, int y) { if (y == 0) return 0; else return sum(x, product(x, y-1)); }