Implement pow(x, n), which calculates x raised to the power n. The exponent n can be negative.
Examples: x = 2.0, n = 10 → 1024.0. x = 2.0, n = -2 → 0.25.
This problem does not ask for mod, but the exponentiation technique is the same.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
(LeetCode 50)
Implement pow(x, n), which calculates x raised to the power n. The exponent n can be negative.
Examples: x = 2.0, n = 10 → 1024.0. x = 2.0, n = -2 → 0.25.
This problem does not ask for mod, but the exponentiation technique is the same.