This function produces power modulo some number . It can be optimized to using
def power ( n , r , q ) : NEW_LINE INDENT total = n NEW_LINE for i in range ( 1 , r ) : NEW_LINE INDENT total = ( total * n ) % q NEW_LINE DEDENT return total NEW_LINE DEDENT def lucasTest ( n ) : NEW_LINE