I\'ve been trying to write a simple function in Java that can calculate a number to the nth power without using loops. I then found the Math.pow(a, b) class...
Use this code.
public int mypow(int a, int e){ if(e == 1) return a; return a * mypow(a,e-1); }