public static void main(String[] args) { System.out.println(pow(3, 4)); } private static int pow(int x, int p) { int copyX = x; for (int i = 1; i < p; i++) { x = x * copyX; } return x; }