
/**
 * Recursive Programming Exercises
 * Philip Peng
 * For Mr. Benum
 * 2007/12/5
 * 
 * Note that all these methods can easily be accomplished via the Math class
 */

public class Operations {

	public static void main(String[] args) {
		System.out.println("5 + 7 = " + addition(5,7));
		System.out.println("5 ^ 7 = " + exponent(5,7));
	}
	
	public static int addition (int n1, int n2) {
		if (n2==0) {
			return n1;
		} else {
			return addition((++n1), (--n2));
		}
	}
	
	// REDO!
	public static int exponent (int n, int exp) {
		if (exp==0) {
			return 1;
		} else {
			return exponent(n, (exp-1), 1*n);
		}
	}
	
	public static int exponent (int n, int exp, int cumul) {
		if (exp==0) {
			return cumul;
		} else {
			return exponent(n, (exp-1), cumul*n);
		}
	}
	

}
