solve problem 27
update isPrimes function to be more efficient