Continued Fractions, Algebraic Numbers and Modular Invariants