public static void diophantine_solution_minimize_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    DIOPHANTINE_SOLUTION_MINIMIZE_TEST tests DIOPHANTINE_SOLUTION_MINIMIZE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    02 December 2006
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int a = 4096;
        const int b = -15625;
        const int c = 46116;

        Console.WriteLine("");
        Console.WriteLine("DIOPHANTINE_SOLUTION_MINIMIZE_TEST");
        Console.WriteLine("  DIOPHANTINE_SOLUTION_MINIMIZE computes a minimal");
        Console.WriteLine("  Euclidean norm solution of a Diophantine equation:");
        Console.WriteLine("    A * X + B * Y = C");

        int x = 665499996;
        int y = 174456828;

        int r = a * x + b * y - c;

        Console.WriteLine("");
        Console.WriteLine("  Coefficients:");
        Console.WriteLine("    A = " + a.ToString().PadLeft(12) + "");
        Console.WriteLine("    B = " + b.ToString().PadLeft(12) + "");
        Console.WriteLine("    C = " + c.ToString().PadLeft(12) + "");
        Console.WriteLine("  Solution:");
        Console.WriteLine("    X = " + x.ToString().PadLeft(12) + "");
        Console.WriteLine("    Y = " + y.ToString().PadLeft(12) + "");
        Console.WriteLine("  Residual R = A * X + B * Y - C:");
        Console.WriteLine("    R = " + r.ToString().PadLeft(12) + "");

        Diophantine.diophantine_solution_minimize(a, b, ref x, ref y);

        r = a * x + b * y - c;

        Console.WriteLine("");
        Console.WriteLine("  DIOPHANTINE_SOLUTION_MINIMIZE returns");
        Console.WriteLine("  the minimized solution:");
        Console.WriteLine("    X = " + x.ToString().PadLeft(12) + "");
        Console.WriteLine("    Y = " + y.ToString().PadLeft(12) + "");
        Console.WriteLine("  Residual R = A * X + B * Y - C:");
        Console.WriteLine("    R = " + r.ToString().PadLeft(12) + "");

        x = 15621;
        y = 4092;

        r = a * x + b * y - c;

        Console.WriteLine("");
        Console.WriteLine("  Here is the minimal positive solution:");
        Console.WriteLine("    X = " + x.ToString().PadLeft(12) + "");
        Console.WriteLine("    Y = " + y.ToString().PadLeft(12) + "");
        Console.WriteLine("  Residual R = A * X + B * Y - C:");
        Console.WriteLine("    R = " + r.ToString().PadLeft(12) + "");
    }