예제 #1
0
        public void Test()
        {
            var euclidian1 = new ExtendedEuclidean(427, 133);
            euclidian1.Solve();

            var euclidian2 = new ExtendedEuclidean(133, 427);
            euclidian2.Solve();

            Assert.AreEqual(7L, euclidian1.GCF);

            Assert.AreEqual(5, euclidian1.FirstCoeficient);
            Assert.AreEqual(-16, euclidian1.SecondCoeficient);

            Assert.AreEqual(euclidian1.FirstCoeficient, euclidian2.SecondCoeficient);
            Assert.AreEqual(euclidian1.SecondCoeficient, euclidian2.FirstCoeficient);
        }
예제 #2
0
        public void Problem531Test()
        {
            // 6 * a + 4 = x
            // 4 * b + 2 = x
            // 6 * a  - 4 * b = -2

            // 6 * 1 + 4 * -1 = 2

            var euclidian = new ExtendedEuclidean(6, -4);
            euclidian.Solve();

            Console.WriteLine(euclidian.FirstCoeficient);
            Console.WriteLine(euclidian.SecondCoeficient);
            Console.WriteLine(euclidian.FirstTCoeficient);
            Console.WriteLine(euclidian.SecondTCoeficient);
            Console.WriteLine(euclidian.GCF);
        }