# Leetcode 50 - Pow(x,n)

`Note:`

- Using normal iteration by multiplying x every time will cause TLE.
`2^32 = (2^16)^2 = ((2^8)^2)^2 = (((2^4)^2)^2)^2 = ((((2^2)^2)^2)^2)^2`

.- Instead of multiplying
`x`

, do`(x^2)^(n/2)`

every time. - Itâ€™s called
`exponentiation by squaring`

. - Leave one
`x`

out when`n`

is odd.

`Question:`

Implement `pow(x, n)`

, which calculates `x`

raised to the power `n`

(i.e., xn).

`Example:`

1 | Input: x = 2.00000, n = 10 |

`Code:`

1 | /** |