The terminating continued fractions

a1, a1 + b2, a1 + b2 b3, a1 + b2 b3 b4 , ...
a2a2 +a3a2 +a3 +a4

reduced to the forms

a1, a1a2 + b2, a1a2a3 + b2a3 + b2a1, a1a2a3a4 + b2a3a4 + b3a1a4 + b4a1a2 + b2b4, ...
1a2a2a3 + b3a2a3a4 + a4b3 + a2b4

are called the successive convergents to the general continued fraction.

Their numerators are denoted by p1, p2, p3, p4...; their denominators by q1, q2, q3, q4....

We have the relations

pn = anpn-1 + bnpn-2, qn = anqn-1 + bnqn-2.

In the case of the fraction

a1 - b2 b3 b4 ...,
a2 - a3 - a4 -