Calculate Power Without using POW method in Java

Calculate Power Without using POW method in Java

In this tutorial, we are going to learn java program to calculate the power of a given number. To calculate the power, user will give the base number and the exponent number. We will calculate Power by multiplying the base number exponent times.

For example

Case1: If the user inputs the base of the number as 2 and exponent as 3
then the output should be ‘8’.
Case2: If the user inputs the base of the number as 5 and exponent as 2.
then the output should be ‘25’.

Power can be calculated using in built pow() method and using manual multiplications. In this tutorial we will see without pow().

Java Program to calculate Power without using POW() function

Output

Power Without using POW java

Explanation

For the input from the user, the base number is 4, and the exponent number is 3. The ‘base e exponent’ will be 4^3, which is 4*4*4 i.e. 64.