def factor(n):
    """Yield the prime factors of n.
    >>> list(factor(360))
    [2, 2, 2, 3, 3, 5]
    """
    isqrt = getattr(math, 'isqrt', lambda x: int(math.sqrt(x)))
    for prime in sieve(isqrt(n) + 1):
        while True:
            quotient, remainder = divmod(n, prime)
            if remainder:
                break
            yield prime
            n = quotient
            if n == 1:
                return
    if n >= 2:
        yield n
Yield the prime factors of n.
    >>> list(factor(360))
    [2, 2, 2, 3, 3, 5]
    
product/runtime/src/main/python/pkg_resources/_vendor/more_itertools/recipes.py