예제 #1
0
        public void NumberOfPrimesLessThen100base2()
        {
            int count = 0;

            for (int i = 1; i < 100; i++)
            {
                m_millerRabin.SetTestedNumber(i.ToOmgNum());
                if (m_millerRabin.IsPrimeToBase(OmgNum.GetConst(2)))
                {
                    count++;
                }
            }
            Assert.AreEqual(count, 24);
        }
예제 #2
0
        private bool _TestFailed(OmgNum num)
        {
            m_primeTester.SetTestedNumber(num.Copy());

            for (int i = 0; i < m_testsPerNumber; i++)
            {
                OmgNum testBase = OmgOp.Random(OmgNum.GetConst(2), num);
                bool   isPrime  = m_primeTester.IsPrimeToBase(testBase);
                testBase.Release();

                if (!isPrime)
                {
                    return(true);
                }
            }

            return(false);
        }