primes: 'primes' method for class 'npsf'

Description Usage Arguments Details Value Author(s) Source See Also Examples

View source: R/primes.R

Description

Provides prime numbers.

Usage

1
  primes(n = NULL, which = NULL, random.primes = FALSE, seed = 7)

Arguments

n

number of prime numbers to be returned. Should be smaller than 100008.

which

numeric. if specific prime numbers are requred. See examples.

random.primes

logical. if n is supplied and random.primes = TRUE, the n primes are chosen on a random basis from 100008 available prime numbers.

seed

set seed for replicability. Default is 17345168.

Details

primes just returns prime numbers, which come from https://primes.utm.edu/lists/small/100000.txt, see https://primes.utm.edu

Value

primes returns prime numbers.

Author(s)

Oleg Badunenko <oleg.badunenko@brunel.ac.uk>

Source

https://primes.utm.edu/lists/small/100000.txt and https://primes.utm.edu

See Also

sf and halton.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  require( npsf )
  
  # obtain first 30 prime numbers
  npsf::primes( 30 )
  
  # the same as
  npsf::primes( n = 30 )
  
  # the result in both case above are 30 prime numbers
  
  # if we use
  npsf::primes( which = 30 )
  
  # the 30th prime is returns, just a scalar
  
  # both cannot be used
  # npsf::primes(n = 30, which = 30, random.primes = FALSE, seed = 17345168)
  # will give a mistake
  
  # you can get random 30 primes, use seed for replicability
  npsf::primes(n = 30, random.primes = TRUE, seed = 17345168)
  
  # obtain specific primes: which take order number(s)
  npsf::primes(which = c(3,67,30, 100008))

npsf documentation built on Nov. 23, 2020, 1:07 a.m.