How to Check If Number is Prime in R (Example Code)

In this R article you’ll learn how to check for prime numbers.

Example: Apply isprime() Function of matlab Package to Check for Prime Numbers

install.packages("matlab")    # Install & load matlab package
library("matlab")
as.logical(isprime(5))        # Check whether number is prime number
# [1] TRUE
as.logical(isprime(6))        # Check whether number is prime number
# [1] FALSE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top