public void LargeSieveIntegerTest(IPrimalityTest p)
 {
     for (int i = 0; i <= pg.largestPrime(); i++)
     {
         Assert.AreEqual(pg.IsPrime(i), p.IsPrime(i));
     }
 }
Exemplo n.º 2
0
        public void StrongPseudoPrimes()
        {
            int iActualPrimeCount     = 0;
            int iActualCompositeCount = 0;
            int iMRPrimeCount         = 0;
            int iMRCompositeCount     = 0;
            int iTotalCount           = 0;

            for (int i = 1; i < pg.largestPrime(); i++)
            {
                iTotalCount++;
                if (pg.IsPrime(i))
                {
                    iActualPrimeCount++;
                }
                if (MillerRabin.MillerRabinPass(2, i))
                {
                    if (MillerRabin.MillerRabinPass(7, i))
                    {
                        iMRPrimeCount++;
                    }
                }
            }
            iActualCompositeCount = iTotalCount - iActualPrimeCount;
            iMRCompositeCount     = iTotalCount - iMRPrimeCount;
            Debug.WriteLine("Total Count: " + iTotalCount);
            Debug.WriteLine("Actual - C: " + iActualCompositeCount + ", P: " + iActualPrimeCount);
            Debug.WriteLine("Miller Rabin - C: " + iMRCompositeCount + ", P: " + iMRPrimeCount);
        }