http://rosettacode.org/wiki/Arithmetic/Rational