Periodic Continued Fractions in Scala