int gcd(int m,int n){ int r,temp; if(m<n){ temp = m;m = n;n = temp; } r = m%n; while(r != 0){ m = n; n = r; r = m%n; } return n; }