static long Prob057() { ContinuedFraction sqrtTwo = new ContinuedFraction(1, new SqrtExpandSequence((new int[] { 2 }).ToList())); long rst = 0; Fraction suffix = new Fraction(1, 2), ONE = Fraction.ONE, TWO = Fraction.Integer(2); int counter = 0; while (counter < 1000) { Fraction sqrt2 = ONE + suffix; if (sqrt2.Numerator.ToString().Length > sqrt2.Denominator.ToString().Length) { rst++; OutputLine(string.Format("{0}th,{1}", counter + 1, sqrt2.ToString())); } counter++; suffix = ONE / (TWO + suffix); } return rst; }
public ContinuedFraction(BigInt baseNum, ExpandSequence expSeq) { _base = Fraction.Integer(baseNum); _expSeq = expSeq; }