Finished the listPrimes function