generatePrime (edit 1)