Not solving correctly. Bad check for primality.