Primality test - Wikipedia, the free encyclopedia

and that page has a link to this page AKS primality test - Wikipedia, the free encyclopedia

If you're doing a big block of numbers though perhaps some sort of sieve would be best.

Generating primes - Wikipedia, the free encyclopedia