You might also want to see Simple primality testing.
In reply to Re: Math help: Finding Prime Numbers by ambrus in thread Math help: Finding Prime Numbers by Ovid