A pitch for a shiny app
Prime numbers are those whole numbers which are only divisible by themselves and the number one.
Examples include:
2, 3, 5, 7, 11, 13, 17, 19, …
Searching for, and finding, prime numbers has been something humanity has done for millenia. There is no complete list of prime numbers, as they are infinite in extent.
One of the more ancient methods for finding the primes is the Sieve of Eratosthenes.
Eratosthenes (c. 276 BC - c. 195 BC) was a Greek mathematician, geographer, poet, astronomer, and music theorist.
From Wikipedia: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
The sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite the multiples of each prime starting with the multiples of 2.
The Sieve of Eratosthenes can be implemented in R. As an example, a sieve function was written, and will provide the prime numbers below a given input, n. For n = 50 for example:
sieve(50)
[1] 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
It is also a simple matter to calculate the number of primes below a given number. For instance, the number of primes below 10,000:
length(sieve(10000))
[1] 1229
One means of visualizing prime numbers, and their distribution, is shown here. The yellow squares represent prime numbers, and the red squares are composite numbers.
This image represents all prime numbers below n = 10,000. For further visualizations, please see the link to the shiny app below.