/* * Student: S.K. Soekhlal * Number: 4860632 * Assignment: 3.4 */ #include #include int gcd (int p, int q) { int r; while (q > 0) /* Loops until the remainder is 0 */ { r = p%q; /* Calculate remainder */ p=q; /* Storing the value of q in p */ q=r; /* Setting q to the value of the remainder to calculate new remainder in the next iteration */ } return p; /* Returning p after the loop finishes */ } int main(){ int a,b; scanf("%d%d",&a,&b); printf("%d\n",gcd(a,b)); return 0; }