step 1: Read n, x
step 2: Set r= 1
step 3: If value of n is 1 then print n and goto step – 8
step 4: Repeat through step-6 until j > 0
step 5: r=r*i
step 6: Update j as j=j-1
step 7: Print r
step 8: Exit
Here is the Java Example for the program RecursionPower
import java.util.Scanner;
public class RecursionPower
{
public static void main(String args[])
{
int n, x, power;
Scanner s=new Scanner(System.in);
System.out.println("Enter values for n and x");
n=s.nextInt();
x=s.nextInt();
power=rec(n,x);
System.out.println("\npower IS :"+power);
}
static int rec(int i,int j)
{
int r=1;
if(i==1)
return i;
else
{
while(j>0)
{
r=r*i;
j--;
}
return r;
}
}
}