Skip to content

Instantly share code, notes, and snippets.

@nna774
Created October 23, 2014 16:30
Show Gist options
  • Save nna774/9b93a36fb47e65718dac to your computer and use it in GitHub Desktop.
Save nna774/9b93a36fb47e65718dac to your computer and use it in GitHub Desktop.
a,b;
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() {
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