public function root($num)
    {
        self::mustBeNumeric($num, 'Root');
        
        $n = is_object($num) ? $num->value : $num;

        if ($n == 0) {
            throw new \InvalidArgumentException('Root must be not nul');
        }

        return new N(pow($this->value, 1 / $n));
    }
public function root($num)
    {
        self::mustBeNumeric($num, 'Root');
        
        $n = is_object($num) ? $num->value : $num;

        if ($n == 0) {
            throw new \InvalidArgumentException('Root must be not nul');
        }

        return new N(pow($this->value, 1 / $n));
    }
public function root ( $ num ) { self :: mustBeNumeric ( $ num , 'Root' ) ; $ n = is_object ( $ num ) ? $ num -> value : $ num ; if ( $ n == 0 ) { throw new \ InvalidArgumentException ( 'Root must be not nul' ) ; } return new N ( pow ( $ this -> value , 1 / $ n ) ) ; }
Gets nth root of current number.

Gets Nth root of given number.

Example:

$n = new N(8);
echo $n->root(3); // '2'
echo $n->root(1); // '8'

@see N::_sqrt() A shorthand for magic getter to get square roots.
@see N::_cubeRoot() A shorthand for magic getter to get cube roots.
@param numeric|N $num Root
@return N
@throws \InvalidArgumentException If root level is 0.
Gets nth root of current number .