Tap here to switch tabs
Problem
Submissions

Problem: Pow(x, n)

Pow(x, n) asks you to compute a number raised to an integer power, returning the resulting value for positive, zero, or negative exponents.

Statement

Implement a function myPow(x, n) that computes x raised to the power n. In simpler words, return xnx^{n}.

Constraints:

  • −100.0<-100.0 < x <100.0< 100.0

  • −231≤-2^{31} \leq n ≤231−1\leq 2^{31} - 1

  • n is an integer

  • Either x is not zero or n >0> 0

  • −104≤xn≤104-10^4 \leq x^n \leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Pow(x, n)

Pow(x, n) asks you to compute a number raised to an integer power, returning the resulting value for positive, zero, or negative exponents.

Statement

Implement a function myPow(x, n) that computes x raised to the power n. In simpler words, return xnx^{n}.

Constraints:

  • −100.0<-100.0 < x <100.0< 100.0

  • −231≤-2^{31} \leq n ≤231−1\leq 2^{31} - 1

  • n is an integer

  • Either x is not zero or n >0> 0

  • −104≤xn≤104-10^4 \leq x^n \leq 10^4