Continued fraction BCMATH programs

1. Euclid's algorithm and the regular continued fraction expansion of a rational number.
2. The optimal continued fraction (OCF) expansion of a rational number.
3. Nearest integer version of Euclid's algorithm.
4. Calculating the fraction represented by the simple continued fraction a0+1/a1+ ··· +1/an.
5. Finding the backward continued fraction of a quadratic irrational.
6. Finding the simple continued fraction of a quadratic irrational.
• Finding the simple continued fraction of √d over a range of consecutive d.
• Finding the period-length of the simple continued fraction of √d using midpoint criteria.
• Finding the positive and negative representations of a quadratic surd, as far as the end of the first period.
• Testing a quadratic surd for being RCF-reduced.
7. Finding the nearest integer continued fraction (NICF-H) of a quadratic irrational.
8. Finding the nearest integer continued fraction (NICF-P)
9. Finding the optimal continued fraction of a quadratic irrational.
• Finding the optimal continued fraction of √d over a range of consecutive d.
10. Finding the nearest square continued fraction of a quadratic irrational.
• Finding the nearest square continued fraction of √d over a range of consecutive d.
• Testing a quadratic surd for being NSCF-reduced.
• Testing a quadratic surd for being NSCF-reduced. This is more elegant than the previous test.
11. Solving the Pell equation x2 – dy2 = ±1 using midpoint criteria,
12. Solving the diophantine equation x2 – xy – (D – 1)y2/4 = ±1, using the nearest square continued fraction of (1+√D)/2, D ≡ 1(mod 4).
13. Calculating the quadratic irrationality whose periodic simple continued fraction is given.
14. Producing a quadratic surd equivalent to a given one.
15. Finding the simple continued fraction of
16. Finding a Sturm sequence for a squarefree polynomial.
17. Factorising
18. Guessing the simple continued fraction expansion of logba.
19. Finding the simple continued fraction of ep/q.
20. Finding the simple continued fraction of (m/n)e1/q.