Finding the first few hundred thousand primes is a trivial problem as many of the answers here show. If you are looking for a challenge with prime numbers try one of these:
- write a program that finds the N-th prime number, where N is supplied by the user when invoking the procedure. For example
(nth-prime 5)
would return 11 since 11 is the fifth prime (assuming primes start at 2). The user will test this function by passing values greater than 10000000 (ten million) tonth-prime
. - write a program that finds the first prime number (not a pseudo prime number) after a value X, where X is supplied by the user when invoking the procedure. For example
(first-prime-after 5)
would return 7, since 7 is the first prime greater than 5. The user will test this function by passing values greater than 18446744073709551616 tofirst-prime-after
(i.e values larger than 64 bits).
Enjoy,
Alex.