MATLAB isprime function

Share:

Description

Array elements that are prime numbers.

Usage

1

Arguments

x

numeric vector or matrix containing nonnegative integer values

Value

Returns an array (or vector) the same size as x containing logical 1 (true) for the elements of x which are prime, and logical 0 (false) otherwise.

Author(s)

H. Borchers hwborchers@googlemail.com, P. Roebuck proebuck@mdanderson.org

See Also

factors, primes

Examples

1
2
3
x <- c(2, 3, 0, 6, 10)
ans  <- isprime(x)	## 1, 1, 0, 0, 0
as.logical(ans)         ## true, true, false, false, false

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.