nth_prime: Calculate and return the nth prime number

View source: R/primes.R

nth_primeR Documentation

Calculate and return the nth prime number

Description

This function will use the primes package unless it either is missing, or if options("zulutils.zerodeps") has been explicitly set to false, in which case it will use a local implementation of the sieve of Erastosthenes.

Usage

nth_prime(n)

Arguments

n

the position of the prime number to be calculated

Value

the nth prime number

Examples

nth_prime(1) # 2
nth_prime(10) # 29
nth_prime(100) # 541
nth_prime(1000) # 7919
nth_prime(10000) # 104729


torfason/zulutils documentation built on Aug. 21, 2023, 5:46 p.m.