Use a matrix to evaluate successive partial values of for phi:

[[0 1],[1 1]]

or root 2:

[[0 1],[1 2]]

or root N:

[[0 (N-(n'*n'))],[0 2n']] (where root n' is the nearest perfect square less than N)

Note that the first row vector of this matrix takes the second entry of the previous result and moves it up to the first entry of the new result (and scales it by a 'factor' measuring the difference from the nearest square in the case general square root). This gives a fraction a/b in the form of the output vector [a b] that, added to n' approximates a square root by an improper fraction, n' + (a/b)

This adapts the method of pure partial fractions. See wikipedia article for the motivation.

This question is for testing whether you are a human visitor and to prevent automated spam submissions.