def factors(n):
    """ Return a sequence of (a, b) tuples where a < b giving factors of n.
        
        Based on https://stackoverflow.com/a/6909532/916373
    """
    return [(i, n//i)  for i in range(1, int(n**0.5) + 1) if n % i == 0]