Determine whether a number is prime How do I determine if a number is prime?  I'm writing a program where a user inputs any integer and from that the program determines whether the number is prime, but how do I go about that?

Algorithm posted by jericson is the best for basic purposes. 
IMHO, for programming competitions and for practical purposes randomized algorithms are best. Rabin-Miller is my favorite. 
Take a look at Rabin-Miller primality testing algorithm code @ TopCoder.
As primes are in P, there is deterministic, polynomial time algorithm called AKS primality test.
