Given a pair of numbers (A, B), you can perform an operation (A+B, B) or (A, A+B). (A, B) is initialized to (1,1).
Given an N>0, find the minimum number of operations needed to perform on (A, B) until A=N or B=N.
Additionally, give the time complexity of the solution.