Skip to content

isprime

specfun · scripts/specfun/isprime.m

: tf = isprime (x)

Return a logical array, the size of x, that is true where the element of x is a prime number.

x must contain non-negative integers of class double, single or any integer class. The test is exact over the whole range of uint64: small inputs are looked up in a sieve, larger ones are examined with trial division followed by the deterministic Miller-Rabin test carried out in exact 64-bit modular arithmetic.