(factors, n, limitp1, use_trial, use_rho, use_pm1,
                       verbose)
Helper function for integer factorization. Checks if ``n``
    is a prime or a perfect power, and in those cases updates
    the factorization and raises ``StopIteration``.
Helper function for integer factorization. Checks if ``n``
    is a prime or a perfect power, and in those cases updates
    the factorization and raises ``StopIteration``.
Helper function for integer factorization . Checks if n is a prime or a perfect power and in those cases updates the factorization and raises StopIteration .
def _check_termination(factors, n, limitp1, use_trial, use_rho, use_pm1,
                       verbose):
    """
    Helper function for integer factorization. Checks if ``n``
    is a prime or a perfect power, and in those cases updates
    the factorization and raises ``StopIteration``.
    """

    if verbose:
        print('Check for termination')

    # since we've already been factoring there is no need to do
    # simultaneous factoring with the power check
    p = perfect_power(n, factor=False)
    if p is not False:
        base, exp = p
        if limitp1:
            limit = limitp1 - 1
        else:
            limit = limitp1
        facs = factorint(base, limit, use_trial, use_rho, use_pm1,
                         verbose=False)
        for b, e in facs.items():
            if verbose:
                print(factor_msg % (b, e))
            factors[b] = exp*e
        raise StopIteration

    if isprime(n):
        factors[int(n)] = 1
        raise StopIteration

    if n == 1:
        raise StopIteration
def _check_termination ( factors , n , limitp1 , use_trial , use_rho , use_pm1 , verbose ) : if verbose : print ( 'Check for termination' ) # since we've already been factoring there is no need to do # simultaneous factoring with the power check p = perfect_power ( n , factor = False ) if p is not False : base , exp = p if limitp1 : limit = limitp1 - 1 else : limit = limitp1 facs = factorint ( base , limit , use_trial , use_rho , use_pm1 , verbose = False ) for b , e in facs . items ( ) : if verbose : print ( factor_msg % ( b , e ) ) factors [ b ] = exp * e raise StopIteration if isprime ( n ) : factors [ int ( n ) ] = 1 raise StopIteration if n == 1 : raise StopIteration