static bool Prob066MinimalPellSolution(int n, ref BigInt rst) { Output("working on {0}: ", n); ContinuedFraction cf = new Sqrt(n).ContinuedFraction; int counter = 0; Fraction expend = cf.ToFraction(counter); BigInt x = expend.Numerator, y = expend.Denominator; while ((x * x) - (n * y * y) != 1) { counter++; expend = cf.ToFraction(counter); x = expend.Numerator; y = expend.Denominator; } OutputLine("{0}^2 - {1}*{2}^2 = 1", x, n, y); if (rst < x) { rst = x; return true; } else { return false; } }