Write a method - pow(x,n) that returns the value of x raised to the power of n (x^{n}). n can be negative!

Examples:

Examples:

`pow(2,3) ==> 8.0`

Need a **hand?** Try out these hints, one at a time.

Think recursively! Multiply the number by itself multiple times to get to the final result.

Account for the fact that the power can be negative.

Try to reduce the number of recusive calls to make your solution faster.

Try to reduce the number of recusive calls to make your solution faster.

Recursion steps :

1. If the value of n is `0`

, `return 1`

.

2. If the value of n is `1`

, `return x`

.

3. If the value of x is `0`

, `return x`

.

4. If n is less than 0, `x`

becomes `1/x`

and `n`

becomes -n.

5. If `n%2 > 0`

, `return x*pow(x*x, n/2)`

.

6. Else return `pow(x*x,n/2)`

public static double pow(double x, int n) { }

**C**

**Java**

**Python**