Fixed prime generator function