I have the following C code. I wanted to know how many recursive calls are made by this function?
int gcd(n,m)
{
if (n%m ==0) return m;
n = n%m;
return gcd(m,n);
}
The answer is O(log n)
. In my view, it should be O(n)
. Please explain how it is O(log n)
.
Thanks in advance.