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...
Try with recursion:
int pow(int base, int power){ if(power == 0) return 1; return base * pow(base, --power); }