Пример #1
0
        static Vector teiler(BigInteger X)
        {
            var teiler = new ArrayList();

            var b2 = BigInteger.valueOf(2L);

            while (X.mod(b2).Equals(BigInteger.ZERO))
            {
                teiler.Add(Symbol.TWO);

                X = X.divide(b2);
            }

            var b3 = BigInteger.valueOf(3L);

            while (X.mod(b3).Equals(BigInteger.ZERO))
            {
                teiler.Add(Symbol.THREE);

                X = X.divide(b3);
            }

            var b5 = BigInteger.valueOf(5L);

            while (X.mod(b5).Equals(BigInteger.ZERO))
            {
                teiler.Add(new Number(5.0));

                X = X.divide(b5);
            }

            var f = BigInteger.valueOf(7L);

            while (!X.Equals(BigInteger.ONE))
            {
                f = kleinsterTeiler(X, f);

                if (f == null)
                {
                    return(null);
                }

                teiler.Add(new Number(f));

                X = X.divide(f);
            }

            return(Vector.Create(teiler));
        }
Пример #2
0
        static BigInteger kleinsterTeiler(BigInteger X, BigInteger start)
        {
            var stop_in = new sbyte[X.bitLength() / 2 + 1];

            stop_in[0] = ( sbyte )1;

            for (int n = 1; n < stop_in.Length; n++)
            {
                stop_in[n] = ( sbyte )0;
            }

            var stop = new BigInteger(stop_in);

            if (start.compareTo(stop) > 0)
            {
                return(X);
            }

            var b30 = BigInteger.valueOf(30L);
            var b   = start.divide(b30);

            b = b.multiply(b30);

            int m = ( int )start.mod(b30).intValue();
            int i = 0;

            while (m > mod[i])
            {
                i++;
            }

            while (start.compareTo(stop) <= 0)
            {
                if (Session.Proc.CheckInterrupt())
                {
                    return(null);
                }

                if (X.mod(start).Equals(BigInteger.ZERO))
                {
                    return(start);
                }

                i++;

                if (i >= mod.Length)
                {
                    i     = 0;
                    b     = b.add(b30);
                    start = b;
                }

                start = start.add(BigInteger.valueOf(( long )moddif[i]));
            }

            return(X);
        }