well, let D be a positive integer whose positive square root s=sqrt(D) is not an integer, xi=(s+ai)/bi = Di + 1/x(i+1) (after Lagrange, Perron, etc.) Proposition: for each i, ai and bi are integers, |ai|0, and bi is a factor of D-ai^2 Proof by induction: 1. true for i=0: a0=0, b0=1 2. if true for i, then a. as Di < xi and bi>0, s+ai -bi Di >0, or bi Di -ai < s, and bi Di -ai > -s, as bi Di>0 and ai0, from a let qi be the second factor in D-ai^2 = bi qi, then x(i+1) = ( s -ai +bi Di )/( qi +2 ai Di -bi Di^2) so, a(i+1) = bi Di -ai, and |a(i+1)|0 c. show that b(i+1) is a factor of D-a(i+1)^2: of course, as D -(ai -bi Di)^2 = D -a(i+1)^2 = bi b(i+1)