Ejemplo n.º 1
0
        public void Run()
        {
            ///////////////////////////////////////////////////////////////////////

            int[] n1 = { 1 };
            int[] n2 = { 2, 5 }; //for 25!
            int[] n3 = { 1 };

            ///////////////////////////////////////////////////////

            int[] n4 = { 1, 0, 0 };
            int[] n5 = { 7 };
            int[] n6 = { 2, 0, 1, 7 };
            int[] n7 = { 2, 5, 6 };
            int[] n8 = { 6, 7, 3, 2, 5, 6, 0 };
            int[] n9 = { 6, 2, 8, 0 };

            ///////////////////////////////////////////////////////////
            HugeInteger H1      = new HugeInteger(n1, 1);
            HugeInteger H2      = new HugeInteger(n2, 1);
            HugeInteger HugeFac = new HugeInteger(n3, 1);

            HugeInteger H100  = new HugeInteger(n4, 1);
            HugeInteger H7    = new HugeInteger(n5, 1);
            HugeInteger H2017 = new HugeInteger(n6, 1);
            HugeInteger H256  = new HugeInteger(n7, 1);
            HugeInteger H7dig = new HugeInteger(n8, 1);
            HugeInteger H4dig = new HugeInteger(n9, 1);


            ///////////////////////////////////////////////////////////////////////////////////////

            Console.WriteLine("for integers, 100 and 7:");
            Console.WriteLine("100 + 7 = {0} ", H100.add(H7).print());     //100+7
            Console.WriteLine("100 - 7 = {0}", H100.subtract(H7).print()); //100-7
            Console.WriteLine("100 * 7 = {0}", H100.product(H7).print());  // 100* 7
            Console.WriteLine("100 / 7 = {0}", H100.division(H7).print()); // 100/7
            Console.WriteLine("100 % 7 = {0}", H100.modulo(H7).print());   // 100 % 7


            //////////////////////////////////////////////////////////////////////////////////////

            Console.WriteLine("\nfor integers, 2017 and 256:");
            Console.WriteLine("2017 + 256 =  {0} ", H2017.add(H256).print());      //2017+256
            Console.WriteLine("2017 - 256 =  {0} ", H2017.subtract(H256).print()); //2017-256
            H2017 = new HugeInteger(n6, 1);                                        //remake huge integers
            H256  = new HugeInteger(n7, 1);                                        //error crops up when huge integers are not remade
            Console.WriteLine("2017 * 256 =  {0} ", H2017.product(H256).print());  //2017*256
            Console.WriteLine("2017 / 256 =  {0} ", H2017.division(H256).print()); //2017/256
            Console.WriteLine("2017 % 256 =  {0} ", H2017.modulo(H256).print());   //2017%256

            ///////////////////////////////////////////////////////////////////////////////

            Console.WriteLine("\nfor integers 6732560 and 6280:");
            Console.WriteLine("6732560 + 6280= {0} ", H7dig.add(H4dig).print());
            Console.WriteLine("6732560 - 6280= {0} ", H7dig.subtract(H4dig).print());
            //H7dig = new HugeInteger(n8, 1); //rebuild huge integers for multiplication
            //H4dig = new HugeInteger(n9, 1); //division, and modulo
            Console.WriteLine("6732560 * 6280= {0} ", H7dig.product(H4dig).print());
            Console.WriteLine("6732560 / 6280= {0} ", H7dig.division(H4dig).print());
            Console.WriteLine("6732560 % 6280= {0} ", H7dig.modulo(H4dig).print());

            ///////////////////////////////////////////////////////////////////////////////////////////////

            Console.Write("\n25! is equal to: ");

            for (int i = 1; i <= 25; i++)
            {
                H1 = H1.product(H2);
                H2 = H2.subtract(HugeFac);
            }

            Console.WriteLine(H1.print());
        }