Our website loads in split second powered by Schema Theme. Thanks to MyThemeShop

Power of a given number using Recursion in Java

Power of a given number, x is a mathematical operation, written as  x^n. involving two numbers, the base x and the exponent  (or index or power)  n. When n is a positive number, exponentiation corresponds to repeated multiplication in other words, a product of n factors. For example, 5^4 = 5*5*5*5 =625

Power of a given number x raised to an exponent n is pow(x,n). Power function, pow(x,n) in Java implemented as native function using bit wise calculations of numbers for faster calculation.

Implementation in Math.java

StrictMath.java

public static native double pow(double a, double b);

Power function Recurrence relation or Algorithm is as below.

 Pow(x,n) implementation in Java using Recursion

Here is the implementation for power of a given number using recursion in java

 Output:

 

Leave a Reply