// Return true if two routines return the same values (when no overflow).
        static public bool IsConsistent(BinCoRoutine routine1, BinCoRoutine routine2)
        {
            long result1, result2;

            for (int n = 0; n < 40; ++n)
            {
                for (int k = 0; k <= n; ++k)
                {
                    try
                    {
                        result1 = routine1(n, k);
                        result2 = routine2(n, k);
                    }
                    catch (OverflowException)
                    {
                        continue;
                    }

                    if (result1 != result2)
                    {
                        Console.WriteLine("Conflicting values at n={0}, k={1}", n, k);
                        return(false);
                    }
                }
            }

            return(true);
        }
        // Test for first failure of the supplied routine.
        static public int GetMaxFullRow(BinCoRoutine routine)
        {
            for (int n = 0; n < 99; ++n)
            {
                for (int k = 0; k <= n; ++k)
                {
                    try
                    {
                        long bc = routine(n, k);
                    }
                    catch (OverflowException)
                    {
                        return(n - 1);
                    }
                }
            }

            return(-1);
        }
        // Return number of milliseconds to perform repetitive calculations.
        static public long GetExecTime(BinCoRoutine routine)
        {
            var reps  = 10000;
            var nMax  = 38;
            var watch = new Stopwatch();

            watch.Start();

            for (int r = 0; r < reps; ++r)
            {
                for (int n = 0; n < nMax; ++n)
                {
                    for (int k = 0; k < n; ++k)
                    {
                        long result = routine(n, k);
                    }
                }
            }

            watch.Stop();
            return(watch.ElapsedMilliseconds);
        }