How many recursive calls are made by this function ?

In the following C function, let n>=m.

int GCD(int n, int m)
{
     if(n%m==0)
          return m;
     n=n%m;
     return GCD(m,n);
}
How many recursive calls are made by this function ?

Answer:

Number of Recursive calls:

  1. 0 call if n==m || if n divisible by m
  2. 1 call if n & m are prime numbers
  3. If n=6, m=4, 1 call
  4. If n=5, m=3, 2 calls
  5. So, it depends if n>m, the recursive calls would stop when n divisible by m.