Definition: A number n in the natural numbers is composite iff there exists a number 1 < k < n in the naturals such that k|n. (The "|" symbol means "divides".)

From the definition of 'divides', for numbers a,b in the naturals, a|b iff there exists a number c in the integers such that a*c=b.

In other words, n is composite iff there exist naturals 1 < k < n and x such that k * x = n.

The inverse: A number n in the naturals is prime iff for all 1 < k < n and x in the naturals, k*x != n. (!= is "does not equal".)

Extension: 1 < k < n, so k=2,3,4,...,n-1. Consider 2 to be 'already' prime, so all numbers k = 2*g for g in the naturals are not prime. Also, consider 3 to be 'already' prime, so all k=3*h for h in the naturals are not prime. So, ignore k=2,3,4,6,8,9,10,..., i.e. let k=6*u±1 for u in the naturals; let n and x be of this form as well, so n=6*m±1 and x=6*v±1 for m, v in the naturals.

Now the number of tests required for primality are reduced by a factor of 3. To test if n is prime, look for any k,x for which k*x=n, or test the equations 6*m±1=(6*u±1)*(6*v±1) for any solutions. Keep in mind that 6*m+1 is a separate case from 6*m-1, but all of 6*u+1, 6*u-1, 6*v+1 and 6*v-1 must be tested.

Distributing the above multiplication yields

6*m±1=36*u*v±6*u±6*v±1
Some manipulation and mod operations reduce this to:

m=6*u*v±u±v
A little more work yields some insight as to some of the larger implications of this equation. One thing in particular is that, if there are *no* u and v in the naturals to satisfy the above equations, then 6*m+1 and 6*m-1 are prime.


Some prime curios:

1234567891 is prime. In fact, so is 12345678901234567891. Both of these may be checked with primo in a very short amount of time. Another interesting prime: (37)14413. That's right: write '37' 1441 times in a row next to each other, then put a 3 on the end and you have a prime. I have seen some conflicting reports, but currently (2^24,036,583)-1 is the largest prime known to date that I can confirm. In terms of digits, this is roughly 7 million decimal digits.

The primes below 1000 are as follows:

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997