Programming Code Center(PCC)
[JAVA]

(PCC)::[How-to-write-Java-Program-to-calculate-the-power-using-recursion]::[java]

File Name : PowerNew.java

//Example: Program to calculate power using recursion
public class Power {

    public static void main(String[] args) {
        int base = 3, powerRaised = 4;
        int result = power(base, powerRaised);

        System.out.printf("%d^%d = %d", base, powerRaised, result);
    }

    public static int power(int base, int powerRaised) {
        if (powerRaised != 0)
            return (base * power(base, powerRaised - 1));
        else
            return 1;
    }
}

Output :

PowerNew.jpg