MRC_Hans
Penultimate Amazing
- Joined
- Aug 28, 2002
- Messages
- 24,961
Really, the algorithm that gives the best understanding of primes, and the patterns in them is the sieve algorithm.
Since primes are not divisible by anything but 1 and themselves, if follows that if you take each prime and "sive" out all numbers that can be divided by it, you'll end up with all the primes.
So, lets for simplicity look at the numbers up to 20:
1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20
1 is a special case, so we skip that and take the next special case, 2. All numbers divisible by 2 go out:
1-2-3--5--7--9--11--13--15--17--19-
Ok, the next prime is 3, knock out all numbers divisible by 3 (except, of course 3):
1-2-3--5--7--11--13--17--19-
If the row of numbers was longer we could go on. but no more is needed now. All we need is test up to the square root of the larget number tested.
This also shows you why there will always be primes, no matter how high you go: The sieve gets ever more coarse.
Hans
Since primes are not divisible by anything but 1 and themselves, if follows that if you take each prime and "sive" out all numbers that can be divided by it, you'll end up with all the primes.
So, lets for simplicity look at the numbers up to 20:
1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20
1 is a special case, so we skip that and take the next special case, 2. All numbers divisible by 2 go out:
1-2-3--5--7--9--11--13--15--17--19-
Ok, the next prime is 3, knock out all numbers divisible by 3 (except, of course 3):
1-2-3--5--7--11--13--17--19-
If the row of numbers was longer we could go on. but no more is needed now. All we need is test up to the square root of the larget number tested.
This also shows you why there will always be primes, no matter how high you go: The sieve gets ever more coarse.
Hans