Prime Number Algorithms with R.
I've recently been read up on prime number theory, which has inspired me to investigate some prime number algorithms myself. First of all, the most obvious way to solve for prime numbers is the brute force method. I.e if you are evaluating whether a number (n) is prime, check if it can be factorized by integers from 2 to n-1. If not, then it is a prime. Needless to say, this is the most inefficient method of finding prime numbers. A more efficient algorithm for finding primes is the Sieve of Eratosthenes. The way that it works is very intuitive. You basically only evaluate primality on numbers less than the square root of n, which allows you to rule out all multiples of those prime numbers. After you have done this, what you are left with is only the prime numbers up to the number n. So why only up to the square root of n? How can you be sure that integers above the square root of n are prime numbers if you don't check them individu...