Question 9549
Use what we call the Sieve of Eratosthanes, a Greek mathematician who is credited with the method.  You list all the integers from 2 to 50 (remember that 1 is NOT a prime number, so you begin with 2!), and you eliminate all the multiples of 2.  That is, you eliminate 4, 6, 8, 10, etc.).  Next, you eliminate all the multiples of 3.  You see, 6, 12, etc are already eliminated, so also eliminate 9, 15, 21, etc.  Next eliminate all the multiples of 5 and of 7.  What remains will be the prime numbers up to 50.  If you want to go higher, you must eliminate multiples of all prime numbers up to the square root of the highest number that you are checking for primes.  For example, to check for primes up to 100, you need to check all prime factors up to 10 (i.e., 7).  To check for primes up to 200, you need to check all prime factors up to square root of 200, which would be up to 14 (actually 13 will be far enough).


R^2 at SCC