Esempio n. 1
0
        public void NumberTheory_Basic_Test()
        {
            var     natural = new Natural(9);
            var     relative_natural = new Natural(38);
            var     valid_natural = new Natural(36);
            int     relativelyprime = 1, gcd = 9, lcm = 342;
            Natural actual;

            actual = natural.Gcd(relative_natural);
            //actual = relative_natural.Gcd(natural);
            Assert.AreEqual(relativelyprime, actual.GetIntValue());
            Console.WriteLine("Relatively Prime (38,9): " + actual.GetIntValue());

            natural = new Natural(9);
            var IsRelativelyPrime = natural.IsRelativelyPrimeTo(relative_natural);

            Assert.AreEqual(true, IsRelativelyPrime);
            Console.WriteLine("Relatively Prime (38,9): " + IsRelativelyPrime);

            natural = new Natural(0);
            var IsPrime = natural.IsPrime();

            Console.WriteLine("Is 38 Prime?: " + IsPrime);

            natural = new Natural(9);
            actual  = natural.Lcm(relative_natural);
            Assert.AreEqual(lcm, actual.GetIntValue());
            Console.WriteLine("Valid LCM (38,9): " + actual.GetIntValue());

            natural = new Natural(9);
            actual  = natural.Gcd(valid_natural);
            Assert.AreEqual(gcd, actual.GetIntValue());
            Console.WriteLine("Valid GCD (36,9): " + actual.GetIntValue());
        }