title: Convert recursive function to a loop (ternary operator)
body: <p>so I have this code from an exam question and I have to convert the recursive part with a loop, now I tried many times but the loop will be endless, here what I did:</p>
  <p>code with recursive</p>
  <pre><code>int f(int n, int m)
  {
      int k;
      if (m == 0) return n;
      k = n % m;
      return k==0 ? m : f(m,k);
  }
  
  </code></pre>
  <p>code with loop</p>
  <pre><code>
  int ff(int n, int m)
  {
      int k;
      if (m == 0) return n;
      k = n % m;
      if (k == 0 ) return m;
      else {
          for(int i = 0 ; k != 0; i++ )
          {
              int h;
              h = k % m;
              if( h == 0 ) return k;
          }
      }
      return m;
  }
  </code></pre>