def convergents(a):
    """
    Generates the convergents of a simple continued fraction.
    Input -- a, an iterable that yields the SCF's terms
    Output -- a sequence of 2-tuples of integers (numerator, denominator)
    Examples:
    >>> list(convergents((1,2,2,2,2)))
    [(1, 1), (3, 2), (7, 5), (17, 12), (41, 29)]
    >>> list(convergents((2,1,2,1,1,4,1)))
    [(2, 1), (3, 1), (8, 3), (11, 4), (19, 7), (87, 32), (106, 39)]
    >>> list(convergents((3,7,15,1,292)))
    [(3, 1), (22, 7), (333, 106), (355, 113), (103993, 33102)]
    >>> a, b = sqrtcfrac(13)
    >>> list(islice(convergents(chain([a], cycle(b))), 8))
    [(3, 1), (4, 1), (7, 2), (11, 3), (18, 5), (119, 33), (137, 38), (256, 71)]
    """
    pm1, qm1, pm2, qm2 = 1, 0, 0, 1
    for n in a:
        p, q = n * pm1 + pm2, n * qm1 + qm2
        yield p, q
        pm1, qm1, pm2, qm2 = p, q, pm1, qm1
