prime number generator and related functions