---
# System prepended metadata

title: 'pow(x, n)'

---

# pow(x, n)
```python=
def pow(x, n):
    res = 1

    while (n > 0): 

        # If y is odd, multiply 
        # x with result 
        if ((n & 1) == 1) : 
            res = res * x 

        # n must be even  
        # now y = y/2 
        n = n >> 1

        # Change x to x^2 
        x = x * x 

    return res 
```