public void ModularExponentiationCorrect(int b, int e, int m, int expectedRes)
        {
            var modularExponentiation = new ModularExponentiation();
            var actualRes             = modularExponentiation.ModularPow(b, e, m);

            actualRes.Should().Be(expectedRes);
        }
        public void ModularExponentiationNegativeMod(int b, int e, int m)
        {
            var    modularExponentiation = new ModularExponentiation();
            Action res = () => modularExponentiation.ModularPow(b, e, m);

            res.Should().Throw <ArgumentException>()
            .WithMessage(String.Format("{0} is not a positive integer", m));
        }
示例#3
0
        public void Test_Power()
        {
            Solutions s      = new Solutions();
            decimal   result = ModularExponentiation.Power(2, -2);

            Assert.AreEqual(.25m, result);

            result = ModularExponentiation.Power(2, 3);

            Assert.AreEqual(8, result);
        }
示例#4
0
        public void Test_ModularExponentiation_Bits()
        {
            Solutions s = new Solutions();

            int result = ModularExponentiation.SolutionWithBits(2, 3, 5);

            Assert.AreEqual(3, result);

            result = ModularExponentiation.SolutionWithBits(2, 5, 13);

            Assert.AreEqual(6, result);
        }
示例#5
0
        public static void TestModularExponentiation()
        {
            var resultModularExponentiation = ModularExponentiation.Run(7, 560, 561);

            Console.WriteLine(resultModularExponentiation);
        }