> For the complete documentation index, see [llms.txt](https://leetcode.realtemirov.uz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leetcode.realtemirov.uz/problems/50.-pow-x-n.md).

# 50. Pow(x, n)

🟧 Medium

## Solution

My Solution

```go
func myPow(x float64, n int) float64 {
    minus := n < 0
    if minus{
        n = -n
    }
    var a float64 = 1
    for n !=0 {
        if n & 1 != 0{
            a *= x
        }
        x *= x
        n = n >> 1
    }
    if minus {
        a = 1/a
    }
    return a
}
```

![result](https://600345290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrSK2xH3txU3tYyDsT8mQ%2Fuploads%2Fgit-blob-9977f969afcf02b1508edf64dc836f1139268a4a%2F50.png?alt=media)

Leetcode: [link](https://leetcode.com/problems/powx-n/description)
