Exemple #1
0
        }//factorial(uint)

        public static void DnC(int end)            //divide and conquer
        {
            uint endIndex = (uint)end;

            if (end == 2)
            {
                VL.Mult(UIntArr[2]);
                UIntArr[0].Mult(UIntArr[1]);
                VL.Mult(UIntArr[0]);
                return;
            }
            if (end < 2)
            {
                UIntArr[0].Mult(UIntArr[1]);
                VL.Mult(UIntArr[0]);
                return;
            }
            for (int i = 0; i < endIndex; i++)
            {
                UIntArr[i].Mult(UIntArr[endIndex]);
                endIndex--;
            }
            if (end % 2 == 1)
            {
                end = (end / 2);
                //if (!firstAdd)
                //{
                //    VL.Mult(UIntArr[end + 1]);
                //    firstAdd = false;
                //}
                //else
                //    VL.Add(UIntArr[end+1]);
            }
            else
            {
                end = (end / 2 - 1);
                if (!firstAdd)
                {
                    if (end >= 1)
                    {
                        VL.Mult(UIntArr[end + 1]);
                    }
                }
                else
                {
                    if (end >= 1)
                    {
                        VL.Add(UIntArr[end + 1]);
                        firstAdd = false;
                    }
                }
            }
            DnC(end);
        }//dnc(uint)