def _continued_frac(num, den):
    """Compute continued fraction of num/den."""
    res = []
    while den:
        q = num // den
        res.append(q)
        num, den = den, num - den*q
    return res