22. Counting the number of primes {VeryLargeIntegers}R Documentation

Counting the Number of Primes Up to a Given Bound

Description

The function primescount returns the number of primes found up to a given bound. The implemented algorithm uses the Miller-Rabin Primality Test to determine whether a number is prime or not. The number of iterations is configurable, to set the desired accuracy.

Usage

primescount(n, iter = 10, bar = TRUE)

## Default S3 method:
primescount(n, iter = 10, bar = TRUE)

## S3 method for class 'numeric'
primescount(n, iter = 10, bar = TRUE)

## S3 method for class 'vli'
primescount(n, iter = 10, bar = TRUE)

Arguments

n

upper bound of the interval in which we want to count the number of primes; object of class vli or 32 bits integer

iter

number of iterations for each number being tested; numeric

bar

to choose if display or not a progress bar; boolean

Author(s)

Javier Leiva Cuadrado

Examples

## Not run: 
## Counting primes up to 200
primescount(n = 200, iter = 10, bar = TRUE)

## Computing the approximation of pi(x)
pi(200)

## Showing the numbers by using the Solovay-Strassen test
primes(n = 200, iter = 10, test = "SS", bar = TRUE)

## End(Not run)

[Package VeryLargeIntegers version 0.2.1 Index]