コード例 #1
0
        private static List <BigInteger>[] GetFirstPoint(BigInteger N)
        {
            List <BigInteger> listNumsN = FactorizationPollard.FactoryToList(N, iterations);
            BigInteger        p         = 0;
            BigInteger        q         = 0;
            BigInteger        k         = 0;

            if (listNumsN.Count == 3)
            {
                p = listNumsN[0];
                q = listNumsN[1];
                k = listNumsN[2];
            }

            List <BigInteger> listNumsPFull = GetAllDivisiors(p - 1);
            List <BigInteger> listNumsQFull = GetAllDivisiors(q - 1);
            List <BigInteger> listNumsKFull = GetAllDivisiors(k - 1);

            List <BigInteger> listNumsPQ = GetAllDivisiors(N / k - 1);
            List <BigInteger> listNumsPK = GetAllDivisiors(N / q - 1);
            List <BigInteger> listNumsKQ = GetAllDivisiors(N / p - 1);

            listNumsPQ = listNumsPQ.Intersect(listNumsKFull).ToList();
            listNumsPK = listNumsPK.Intersect(listNumsQFull).ToList();
            listNumsKQ = listNumsKQ.Intersect(listNumsKFull).ToList();

            return(new List <BigInteger>[] { listNumsPQ, listNumsPK, listNumsKQ });
        }
コード例 #2
0
        private static List <BigInteger> GetAllDivisiors(BigInteger num)
        {
            List <BigInteger> listNums     = FactorizationPollard.FactoryToList(num, iterations);
            List <BigInteger> listNumsFull = new List <BigInteger>();

            listNumsFull.AddRange(listNums);

            BigInteger _result = 1;

            for (int j = 0; j < listNums.Count - 1; j++)
            {
                for (int i = j + 1; i < listNums.Count; i++)
                {
                    BigInteger mult = listNums[j] * listNums[i];
                    _result = _result * mult;

                    if (!listNumsFull.Contains(mult) && mult <= num && num % mult == 0)
                    {
                        listNumsFull.Add(mult);
                    }

                    if (!listNumsFull.Contains(_result) && _result <= num && num % _result == 0)
                    {
                        listNumsFull.Add(_result);
                    }
                    else
                    {
                        _result = 1;
                    }
                }
            }

            for (int j = 0; j < listNumsFull.Count - 1; j++)
            {
                for (int i = j + 1; i < listNumsFull.Count; i++)
                {
                    _result = listNumsFull[j] * listNumsFull[i];
                    if (!listNumsFull.Contains(_result) && _result <= num && num % _result == 0)
                    {
                        listNumsFull.Add(_result);
                    }
                }
            }
            listNumsFull.Add(1);
            listNumsFull.Sort();
            return(listNumsFull.Distinct().ToList());
        }
コード例 #3
0
        private static List <BigInteger> GetFirstPoint(BigInteger N)
        {
            List <BigInteger> listNumsN = FactorizationPollard.FactoryToList(N, iterations);
            BigInteger        p         = 0;
            BigInteger        q         = 0;

            if (listNumsN.Count == 2)
            {
                p = listNumsN[0];
                q = listNumsN[1];
            }

            List <BigInteger> listNumsP     = FactorizationPollard.FactoryToList(p - 1, iterations);
            List <BigInteger> listNumsPFull = new List <BigInteger>();

            listNumsPFull.AddRange(listNumsP);

            BigInteger _result = 1;

            for (int j = 0; j < listNumsP.Count - 1; j++)
            {
                for (int i = j + 1; i < listNumsP.Count; i++)
                {
                    BigInteger mult = listNumsP[j] * listNumsP[i];
                    _result = _result * mult;

                    if (!listNumsPFull.Contains(mult) && mult <= p - 1 && (p - 1) % mult == 0)
                    {
                        listNumsPFull.Add(mult);
                    }

                    if (!listNumsPFull.Contains(_result) && _result <= p - 1 && (p - 1) % _result == 0)
                    {
                        listNumsPFull.Add(_result);
                    }
                    else
                    {
                        _result = 1;
                    }
                }
            }

            for (int j = 0; j < listNumsPFull.Count - 1; j++)
            {
                for (int i = j + 1; i < listNumsPFull.Count; i++)
                {
                    _result = listNumsPFull[j] * listNumsPFull[i];
                    if (!listNumsPFull.Contains(_result) && _result <= p - 1 && (p - 1) % _result == 0)
                    {
                        listNumsPFull.Add(_result);
                    }
                }
            }

            List <BigInteger> listNumsQ     = FactorizationPollard.FactoryToList(q - 1, iterations);
            List <BigInteger> listNumsQFull = new List <BigInteger>();

            listNumsQFull.AddRange(listNumsQ);
            _result = 1;
            for (int j = 0; j < listNumsQ.Count - 1; j++)
            {
                for (int i = j + 1; i < listNumsQ.Count; i++)
                {
                    BigInteger mult = listNumsQ[j] * listNumsQ[i];
                    _result = _result * mult;

                    if (!listNumsQFull.Contains(mult) && mult <= q - 1 && (q - 1) % mult == 0)
                    {
                        listNumsQFull.Add(mult);
                    }

                    if (!listNumsQFull.Contains(_result) && _result <= q - 1 && (q - 1) % _result == 0)
                    {
                        listNumsQFull.Add(_result);
                    }
                    else
                    {
                        _result = 1;
                    }
                }
            }
            _result = 1;
            for (int j = 0; j < listNumsQFull.Count - 1; j++)
            {
                for (int i = j + 1; i < listNumsQFull.Count; i++)
                {
                    _result = listNumsQFull[j] * listNumsQFull[i];
                    if (!listNumsQFull.Contains(_result) && _result <= q - 1 && (q - 1) % _result == 0)
                    {
                        listNumsQFull.Add(_result);
                    }
                }
            }

            List <BigInteger> listNumsIntersected = listNumsQFull.Intersect(listNumsPFull).ToList();

            listNumsIntersected.Add(1);
            return(listNumsIntersected);
        }