Thursday, April 24, 2008

GCD

Examine this code for GCD:
public static int gcd(int m, int n)
{
if(m==n) return n;
else if(m < n) return gcd(m,n-m);
else return gcd(m-n,n);
}
//WHY DOES THIS WORK???

No comments: