Helper function that calculates F [ ] [ ] raise to the power n and puts the result in F [ ] [ ] Note that this function is designed only for fib ( ) and won 't work as general power function
def power ( F , n , m ) : NEW_LINE INDENT if ( n == 0 or n == 1 ) : NEW_LINE INDENT return ; NEW_LINE DEDENT M = [ [ 1 , 1 ] , [ 1 , 0 ] ] ; NEW_LINE power ( F , n // 2 , m ) ; NEW_LINE multiply ( F , F , m ) ; NEW_LINE if ( n % 2 != 0 ) : NEW_LINE INDENT multiply ( F , M , m ) ; NEW_LINE DEDENT DEDENT