Example #1
0
bool IsPrime(const Integer &p)
{
	if (p <= s_lastSmallPrime)
		return IsSmallPrime(p);
	else if (p <= Singleton<Integer, NewLastSmallPrimeSquared>().Ref())
		return SmallDivisorsTest(p);
	else
		return SmallDivisorsTest(p) && IsStrongProbablePrime(p, 3) && IsStrongLucasProbablePrime(p);
}
Example #2
0
bool IsPrime(const Integer &p)
{
	static const Integer lastSmallPrimeSquared = Integer(lastSmallPrime).Squared();

	if (p <= lastSmallPrime)
		return IsSmallPrime(p);
	else if (p <= lastSmallPrimeSquared)
		return SmallDivisorsTest(p);
	else
		return SmallDivisorsTest(p) && IsStrongProbablePrime(p, 3) && IsStrongLucasProbablePrime(p);
}