Ejemplo n.º 1
0
 public static int Gcd(out long t, int a, int b, Method m = Method.EUCLIDS)
 {
     Stopwatch time = Stopwatch.StartNew();
     int d = Methods[m](a, b);
     time.Stop();
     t = time.ElapsedTicks;
     return d;
 }
Ejemplo n.º 2
0
        public static int Gcd(Method m = Method.EUCLIDS, params int[] args)
        {
            if (args == null) throw new NullReferenceException();
            if (args.Length < 2) throw new Exception("To few arguments.");

            int d = Methods[m](args[0], args[1]);
            for (int i = 1; i < args.Length; i++)
            {
                int g = Methods[m](d, args[i]);
                if (d != 1 && g != 1) d = g;
                else break;
            }

            return d;
        }
Ejemplo n.º 3
0
        public static int Gcd(out long t, Method m = Method.EUCLIDS, params int[] args)
        {
            if (args == null) throw new NullReferenceException();
            if (args.Length < 2) throw new Exception("To few arguments.");

            Stopwatch time = Stopwatch.StartNew();
            int d = Gcd(m, args);
            time.Stop();
            t = time.ElapsedTicks;
            return d;
        }
Ejemplo n.º 4
0
 public static int Gcd(int a, int b, Method m = Method.EUCLIDS)
 {
     return Methods[m](a, b);
 }