

In other words, we can say that the prime numbers can’t be divided by other numbers than itself and 1. This is why it works for $100$ but not $121$. A Prime Number is a number that should be greater than 1 and it only is divided by 1 and itself.

My program took only 17 seconds to generate the 10 files. Hence, to verify the primality of $149$, you need to check for divisibility by all the primes below $\sqrt$. Prime Number Lists View the Prime Numbers in the range 0 to 10,000 in a neatly formatted table, or download any of the following text files: I generated these prime numbers using the 'Sieve of Eratosthenes' algorithm. With this observation, you might deduce that you need to check also the divisibility by prime numbers higher than $7$ like $11$, $13$.īut where should we stop ? There is an infinity of prime numbers and you can't possibly check divisibility by all of them ! This issue is solved by noticing that a number $n$ can't have all its prime divisors higher than $\sqrt n$. You noticed that it works for numbers below $100$, and others have already pointed out that it fails for $121 = 11\times 11$. Example: find all prime numbers below 100.

Your algorithm relies on a simple observation : a number ($\geq2$) is prime if and only if it can be divided by another number than $1$ and itself. 1) Create a list of consecutive integers from 2 through n: (2,3,4. The fact that you verified that your idea works for all numbers below $100$ (except for $1$, which isn't considered prime, but let's put that aside) proves that your algorithm is correct for the range $$. Your ideas are interesting for the problem of "finding all prime numbers within a range".
