Improved prime generator