Learn R Programming

primes (version 1.6.0)

k_tuple: Prime k-tuples

Description

Use prime k-tuples to create lists of twin primes, cousin primes, prime triplets, and so forth.

Usage

k_tuple(min, max, tuple)

sexy_prime_triplets(min, max)

twin_primes(min, max)

cousin_primes(min, max)

sexy_primes(min, max)

third_cousin_primes(min, max)

Value

A list of vectors of prime numbers satisfying the condition of tuple.

Arguments

min

the lower bound of the sequence.

max

the upper bound of the sequence.

tuple

an integer vector representing the target k-tuple pattern.

Author

Paul Egeler, MS

Details

You can construct your own tuples and generate series of primes using k_tuple; however, there are functions that exist for some of the named relationships. They are listed below.

  • twin_primes: represents c(0,2).

  • cousin_primes: represents c(0,4).

  • third_cousin_primes: represents c(0,8).

  • sexy_primes: represents c(0,6).

  • sexy_prime_triplets: represents c(0,6,12). (This relationship is unique in that \(p + 18\) is guaranteed to be composite.)

The term "third cousin primes" is of the author's coinage. There is no canonical name for that relationship to the author's knowledge.

Examples

Run this code
# All twin primes up to 13
twin_primes(2, 13) # Identical to `k_tuple(2, 13, c(0,2))`
## [[1]]
## [1] 3 5
##
## [[2]]
## [1] 5 7
##
## [[3]]
## [1] 11 13

# Some prime triplets
k_tuple(2, 19, c(0,4,6))
## [[1]]
## [1]  7 11 13
##
## [[2]]
## [1] 13 17 19

Run the code above in your browser using DataLab