pyspeedup/algorithms/_invMod.py
def _iM(dividend,divisor):
    '''A recursive helper function for use in inverting.'''
    (q,r)=divmod(dividend,divisor) #Python native function that performs Euclidean division.
    if r==0:
        if divisor!=1:
            raise Exception("Number not invertible in given set of integers.")
        return (0,1)
    prev,solution=_iM(divisor,r)
    #Python syntax for quick value reassignment, which allows for swapping without a temporary variable.
    prev,solution=-solution,-(prev+q*solution) #Negatives account for sign change in algorithm lazily.
    return prev,solution
A recursive helper function for use in inverting.
A recursive helper function for use in inverting.
A recursive helper function for use in inverting .
def _iM(dividend,divisor):
    (q,r)=divmod(dividend,divisor) 
    if r==0:
        if divisor!=1:
            raise Exception("Number not invertible in given set of integers.")
        return (0,1)
    prev,solution=_iM(divisor,r)
    prev,solution=-solution,-(prev+q*solution) 
    return prev,solution
def _iM ( dividend , divisor ) : ( q , r ) = divmod ( dividend , divisor ) if r == 0 : if divisor != 1 : raise Exception ( "Number not invertible in given set of integers." ) return ( 0 , 1 ) prev , solution = _iM ( divisor , r ) prev , solution = - solution , - ( prev + q * solution ) return prev , solution
A recursive helper function for use in inverting.
A recursive helper function for use in inverting .
'''A recursive helper function for use in inverting.''' #Python native function that performs Euclidean division. #Python syntax for quick value reassignment, which allows for swapping without a temporary variable. #Negatives account for sign change in algorithm lazily.
dividend
divisor