one can use recursion for this....

int gcd(int u,int v)
{
if(u==0) return v;
else if(v==0) return u;
else if(u%2==0&&v%2==0) return 2*gcd(u/2,v/2);
else if(u%2==0&&v%2!=0) return gcd(u/2,v);
else if(v%2==0&&u%2!=0) return gcd(u,v/2);
else if(u>v) return gcd((u-v)/2),v);
else if(u<=v)
       return gcd(u,(v-u)/2);

with regards
naveen

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to