19 lines
313 B
C
19 lines
313 B
C
/* A program to perform Euclid s Algorithm to compute gcd. */
|
|
int gcd(int u, int v) {
|
|
if (v == 0) {
|
|
return u;
|
|
} else {
|
|
return gcd(v, u-u/v*v);
|
|
}
|
|
/* u-u/v*v* == u mod v */
|
|
}
|
|
|
|
void main() {
|
|
int x;
|
|
int y;
|
|
x = input();
|
|
y = input();
|
|
output(gcd(x, y));
|
|
return;
|
|
}
|