protected function _prime()
    {
        if ($this->value < 2) {
            return false;
        }

        if (!$this->_decimal()->zero) {
            throw new \RuntimeException(
                'You cannot test if number is prime numer if it is not an integer'
            );
        }

        $max = floor(sqrt($this->value));

        for ($i = 2; $i <= $max; $i++) {
            if ($this->value % $i == 0) {
                return false;
            }
        }

        return true;
    }
protected function _prime()
    {
        if ($this->value < 2) {
            return false;
        }

        if (!$this->_decimal()->zero) {
            throw new \RuntimeException(
                'You cannot test if number is prime numer if it is not an integer'
            );
        }

        $max = floor(sqrt($this->value));

        for ($i = 2; $i <= $max; $i++) {
            if ($this->value % $i == 0) {
                return false;
            }
        }

        return true;
    }
protected function _prime ( ) { if ( $ this -> value < 2 ) { return false ; } if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'You cannot test if number is prime numer if it is not an integer' ) ; } $ max = floor ( sqrt ( $ this -> value ) ) ; for ( $ i = 2 ; $ i <= $ max ; $ i ++ ) { if ( $ this -> value % $ i == 0 ) { return false ; } } return true ; }
Checks if current number is prime number

Checks whether current number is prime number. Prime number can only by
divided by itself and by one.

Example:

$n = new N(5);
var_dump($n->prime); // true
$n = new N(6);
var_dump($n->prime); // false

@see N::$prime Magic getter way
@return boolean
@throws \RuntimeException If current number is not an integer.
Checks if current number is prime number