Function isPrime

Test whether a value is prime: has no divisors other than itself and one. The function supports type number, bignumber.

The function is evaluated element-wise in case of Array or Matrix input.




Parameter Type Description
x number | BigNumber | Array | Matrix Value to be tested


Type Description
boolean Returns true when x is larger than zero. Throws an error in case of an unknown data type.


isPrime(3);                     // returns true
isPrime(-2);                    // returns false
isPrime(0);                     // returns false
isPrime(-0);                    // returns false
isPrime(0.5);                   // returns false
isPrime('2');                   // returns true
isPrime([2, 17, 100]');           // returns [true, true, false]

See also

isNumeric, isZero, isNegative, isInteger