spectatorx - 1 year ago 67

PHP Question

I'm trying to create simple advanced calculator just for fun and currently I'm facing a problem.

In PHP we have a function

`sqrt()`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Using `pow`

:

```
function nthRoot($number, $nthRoot) {
return pow($number, (1/$nthRoot));
}
```

So, `nthRoot(32, 5) == 2`

, as anything to the power of (1/N) is the same as taking the Nth root of that number. E.g.,

`sqrt(4) == 4^(1/2)`

,`sqrt(sqrt(16)) == 16^(1/4)`

, where`sqrt(sqrt((N))`

is the same as saying`the square root of the square root`

, i.e., "the 4th root".

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**