The function computes the periodic continued fraction of the square root of
  an integer that itself shall not be a square (because otherwise the integer
  square root will be returned). Note that the continued fraction of an
  irrational quadratic number is always a periodic continued fraction.
The first term is the biggest integer below sqrt(d) and the rest is
  the period of the continued fraction. The period is always exact, there is
  no floating point inaccuracy involved (though integer overflow may happen
  for very long fractions).
The underlying algorithm is sometimes called "The Fundamental Algorithm
  for Quadratic Numbers". The function will be utilized especially when
  solving Pell's equation.