Beispiel #1
0
        static void Main(string[] args)
        {
            MyTimer timer = new MyTimer();

            //long NumberToCheck = 54996816813;
            long NumberToCheck = 5791;

            timer.Start();
            Console.WriteLine("Factorizing:\t{0:N0}", NumberToCheck);
            List <long> NumberFactors = Factorization.Factorize(NumberToCheck);

            Console.WriteLine("Factorization is:");
            int counter = NumberFactors.Count;

            foreach (int factor in NumberFactors)
            {
                counter--;
                Console.Write(factor);
                if (counter != 0)
                {
                    Console.Write("x");
                }
            }
            Console.WriteLine("");
            Console.WriteLine("Calculation took: {0}", timer.Elapsed);

            Console.Read();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Rho Pollard
            var primeA = "99194853094755497".ToOmgNum();
            var primeB = "2971215073".ToOmgNum();

            var primesProd = OmgOp.Multiply(primeA, primeB);

            var polard = new PolardFactorization();
            var factor = polard.FindFactor(primesProd);

            Console.WriteLine($"factor: {factor}");

            // Rho Discrete Log

            var rhoLogFinder = new RhoLog();

            (OmgNum a, OmgNum b, OmgNum p)log = (5.ToOmgNum(), 3.ToOmgNum(), 2017.ToOmgNum());
            var discreteLog = rhoLogFinder.FindLog(log.a, log.b, log.p);

            Console.WriteLine($"{discreteLog} : {OmgOp.Pow(log.a, discreteLog, log.p)}");

            // Factorization

            var factorizer    = new Factorization();
            var factorization = factorizer.Factorize("63782453".ToOmgNum());

            Console.WriteLine($"factorization: {String.Join(' ', factorization.Select(x => ($"{x.Key}^{x.Value}")))}");
            // EulerF

            var euler = factorizer.EulerFunction("63782453".ToOmgNum());

            Console.WriteLine($"euler: {euler}");

            // MobiusF

            var mobius1 = factorizer.Mobius("63782453".ToOmgNum());
            var mobius2 = factorizer.Mobius("4".ToOmgNum());

            Console.WriteLine($"mobius1: {mobius1}");
            Console.WriteLine($"mobius2: {mobius2}");
        }