Example #1
0
 private bool IsProbablePrime(BigInteger x, int iterations)
 {
     /*
      * Primes class for FIPS 186-4 C.3 primality checking
      */
     return(!Primes.HasAnySmallFactors(x) && Primes.IsMRProbablePrime(x, random, iterations));
 }
 protected bool isProbablePrime(BigInteger x)
 {
     /*
      * Primes class for FIPS 186-4 C.3 primality checking
      */
     return(!Primes.HasAnySmallFactors(x) && Primes.IsMRProbablePrime(x, param.Random, iterations));
 }
Example #3
0
        public void TestHasAnySmallFactors()
        {
            for (int iterations = 0; iterations < ITERATIONS; ++iterations)
            {
                BigInteger prime = RandomPrime();
                Assert.False(Primes.HasAnySmallFactors(prime));

                // NOTE: Loop through ALL small values to be sure no small primes are missing
                for (int smallFactor = 2; smallFactor <= Primes.SmallFactorLimit; ++smallFactor)
                {
                    BigInteger nonPrimeWithSmallFactor = BigInteger.ValueOf(smallFactor).Multiply(prime);
                    Assert.True(Primes.HasAnySmallFactors(nonPrimeWithSmallFactor));
                }
            }
        }