--- from: http://rosettacode.org/wiki/Pell's_equation note: Mathematics