isPrime

Test if a number is a prime.

A prime number is defined as an integer value greater than 1 which is only divisible by 1 and itself.

Usage

var isPrime = require( '@stdlib/math/base/assert/is-prime' );

isPrime( x )

Tests if a number is a prime.

var bool = isPrime( 7.0 );
// returns true

Examples

var isPrime = require( '@stdlib/math/base/assert/is-prime' );

var bool = isPrime( 11.0 );
// returns true

bool = isPrime( 3.14 );
// returns false

bool = isPrime( NaN );
// returns false
Did you find this page helpful?