
public class Powers {
    /**
     * compute base^exponent
     * @param base base of exponentiation
     * @param exponent power of exponentiation
     * @return base raised to the exponent power
     */
    public static int power(int base, int exponent){
        if (exponent==0) {
            return 1;   // base^0 = 1
        }
        else {
            // base^power = base*(base^(power-1))
            int subproblem=power(base,exponent-1);
				return base*subproblem;
        }
    }
    public static void main(String[] args) {
        System.out.println(power(3,4));
    }
}
