def contfrac_rat(n, d):
    """
    Returns the simple continued fraction of the rational number n/d.
    Note the similarity to Euclid's algorithm.
    Input:
        num -- integer
        den -- positive integer coprime to num
    Output: sequence of integers
    Examples:
    >>> list(contfrac_rat(3, 2))
    [1, 2]
    >>> list(contfrac_rat(103993, 33102))
    [3, 7, 15, 1, 292]
    >>> list(contfrac_rat(*list(convergents((1,2,2,2,2,2,2,2,2,2)))[-1]))
    [1, 2, 2, 2, 2, 2, 2, 2, 2, 2]
    >>> list(convergents(contfrac_rat(103993, 33102)))[-1]
    (103993, 33102)
    """
    while d != 0:
        yield n // d
        n, d = d, n % d
