isprime - Determine which array elements are prime - MATLAB (original) (raw)
Main Content
Determine which array elements are prime
Syntax
Description
TF = isprime([X](#btsyhna-1-X))
returns a logical array containing1
(true)
where the elements of the array X
are prime numbers, and 0
(false)
where they are not.
Examples
tf = isprime([2 3 0 6 10])
tf = 1×5 logical array
1 1 0 0 0
2
and 3
are prime, but 0
, 6
, and 10
are not.
x = uint16([333 71 99]); tf = isprime(x)
tf = 1×3 logical array
0 1 0
71
is prime, but 333
and 99
are not.
Input Arguments
Input values, specified as a scalar, vector, or array of real, nonnegative integer values.
Example: 17
Example: [1 2 3 4]
Example: int16([127 255 4095])
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Extended Capabilities
Usage notes and limitations:
- The maximum double precision input is
2^33
. - The maximum single precision input is
2^25
. - The input
X
cannot have typeint64
oruint64
.
Version History
Introduced before R2006a