title: Time complexity of following function
body: <p>In the following C++ function, let n >= m.</p>
  
  <pre><code>int gcd(int n, int m) {
              if (n%m ==0) return m;
              if (n &lt; m) swap(n, m);
              while (m &gt; 0) {
                  n = n%m;
                  swap(n, m);
              }
              return n;
      }
  </code></pre>
  
  <p>What is the time complexity of the above function assuming n > m?
  Answer to this question is O(log n), but I am not getting how it is calculated?</p>