Java Program to find Power using Recursion

In this post, we will learn how to calculate the power of any number using recursion. Implementation Using Java: import java.util.Scanner;
class PowerRecursion
public static int powerOf(int n, int x)
return 1;
return n*powerOf(n,x-1);
public static void main(String[] args)
Scanner sc=new Scanner(;
System.out.println("Enter the number ");
int n=sc.nextInt();
System.out.println("Enter the power ");
int x=sc.nextInt();
} Output:
Enter the number
Enter the power
25 Happy Coding! Follow us on Instagram @programmersdoor Join us on Telegram @programmersdoor Please write comments if you find any bug in above code/algorithm, or find other ways to solve the same problem. Follow Programmers Door for more. #blog #interview #placement #learn #computer #science

        Contact Us

  • LinkedIn
  • Facebook
  • Instagram

©2023 by Programmers Door