2019-09-11 09:08:22 +00:00
|
|
|
/*
|
|
|
|
* Student: S.K. Soekhlal
|
|
|
|
* Number: 4860632
|
|
|
|
* Assignment: 3.4
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
#include<stdio.h>
|
|
|
|
|
|
|
|
int gcd (int p, int q)
|
|
|
|
{
|
2019-09-11 09:30:23 +00:00
|
|
|
int r;
|
2019-09-13 08:27:00 +00:00
|
|
|
while (q > 0){ /* Loops until the remainder is 0 */
|
2019-09-11 09:30:23 +00:00
|
|
|
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 */
|
2019-09-11 09:26:22 +00:00
|
|
|
}
|
2019-09-11 09:30:23 +00:00
|
|
|
return p; /* Returning p after the loop finishes */
|
2019-09-11 09:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-09-11 09:26:22 +00:00
|
|
|
|
|
|
|
|
2019-09-11 09:08:22 +00:00
|
|
|
int main(){
|
|
|
|
int a,b;
|
|
|
|
scanf("%d%d",&a,&b);
|
|
|
|
printf("%d\n",gcd(a,b));
|
|
|
|
return 0;
|
|
|
|
}
|