Example #1
0
        public void TotientPerformance()
        {
            if (!bRunExpensive)
            {
                return;
            }
            Ticker  tick = new Ticker();
            Totient tot  = new Totient(p, 9900000);

            tick.Tick("Generated first ~ten million");
            int iMax;

            iMax = 0;
            while (!tick.SecondsElapsed(5) && iMax < 1000000)
            {
                iMax++;
                tot.Crappy(iMax);
            }
            tick.Tick("Crappy Max Value = " + iMax);
            iMax = 0;
            while (!tick.SecondsElapsed(5) && iMax < 1000000)
            {
                iMax++;
                tot.OK(iMax);
            }
            tick.Tick("OK Max Value = " + iMax);
            iMax = 0;
            while (!tick.SecondsElapsed(5) && iMax < 1000000)
            {
                iMax++;
                tot.Best(iMax);
            }
            tick.Tick("Best Max Value = " + iMax);
        }
Example #2
0
        public void PrecalcTest()
        {
            Totient t = new Totient(p, iaTots.Length);

            for (int i = 1; i < iaTots.Length; i++)
            {
                Assert.AreEqual(iaTots[i], t.Best(i));
            }
            if (bRunExpensive)
            {
                //t = new Totient(p, 9900000);
                Assert.AreEqual(3015360, t.Best(9799998));
                Assert.AreEqual(2799792, t.Best(9799398));
                Assert.AreEqual(3195896, t.Best(9796398));
                Assert.AreEqual(400000, t.Best(1000000));
            }
        }