One quick method to generate a list of all prime numbers that are lesser than N is the Sieve of Eratosthenes:
- Create a list of all numbers from 2 to N.
- Start with the first prime number, 2, and cross out all multiples of 2 from the list (4, 6, 8, etc.).
- Move to the next unmarked number, 3, which is also prime, and cross out all multiples of 3 from the list (6, 9, 12, etc.).
- Continue this process, taking the next unmarked number as the next prime, and crossing out all its multiples.
- When you reach the square root of N, all remaining unmarked numbers are prime.
The resulting list will contain all prime numbers less than N.