Skip to content

Instantly share code, notes, and snippets.

@nna774
Created October 23, 2014 16:31
Show Gist options
  • Save nna774/6f17b2a0799539537fa4 to your computer and use it in GitHub Desktop.
Save nna774/6f17b2a0799539537fa4 to your computer and use it in GitHub Desktop.
gcd(x,y) {
if (x < y) return gcd(y, x);
if (y == 0) return x;
gcd(y, x % y);
}
lcm(x,y) {
x / gcd(x, y) * y;
}
main(a,b) {
scanf("%d%d", &a, &b);
printf("gcd(%d, %d) = %d, lcm(%d, %d) = %d\n", a, b, gcd(a, b), a, b, lcm(a, b));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment