Just as an aside, if you're generating a list of primes (as opposed to determining whether or not an arbitrary number is prime), the
Sieve of Eratosthenes is a fairly intuitive and simple algorithm for doing just that. It's easy to implement, and might be a fun programming excercise for you. It's by no means necessary for the requirements of the program, but it will surely impress your teacher (if this is an assignment).