Generate and Test for Prime Numbers

Functions to test whether a number is prime and generate the prime numbers within a specified range. Based around an implementation of Wilson's theorem for testing for an integer's primality.


Author: Oliver Keyes
License: MIT
Status: In development

Description

primes is a simple package that does two things; tests for prime numbers, and generates prime numbers. Testing can be done with is_prime, which accepts an integer vector of any length and returns a logical vector of equal length containing, for each element, whether it is prime (TRUE) or not (FALSE). generate_primes generates every prime number between min and max, where min is 0 by default.

Both functions rely on a C++ implementation of Wilson's theorem for testing primality; in theory this is a very slow test, but in practice, due to the restrictions R places around maximum integer sizes, it's fast enough for our needs.

Installation

For the development version:

News

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("primes")

0.1.0 by Oliver Keyes, 4 years ago


Browse source code at https://github.com/cran/primes


Authors: Oliver Keyes


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp

Suggests testthat

Linking to Rcpp


See at CRAN