isPrime n = isPrime' 2 where isPrime' m | m > round(sqrt n) = True | mod (truncate n) m /= 0 = isPrime' (m + 1) | otherwise = False