Learn R Programming

primes (version 1.6.0)

is_prime: Test for Prime Numbers

Description

Test whether a vector of numbers is prime or composite.

Usage

is_prime(x)

Value

A logical vector.

Arguments

x

an integer vector containing elements to be tested for primality.

Author

Os Keyes and Paul Egeler, MS

Examples

Run this code
is_prime(4:7)
## [1] FALSE  TRUE FALSE  TRUE

is_prime(1299827)
## [1] TRUE

Run the code above in your browser using DataLab