###### tags: `I2P(I)Hu2023`
# 14041 - LCM + GCD
> by schdoel
## Brief
Given two integers *x* and *y*, calculate the least common multiple and greatest common divisor of two integers.
## Solution
First calculate the gcd just like the GCD problem GCD(x,y).
LCD = (*x * y)* / GCD(*x,y*)
## Reference Code
```cpp=
#include<stdio.h>
int gcd(int x, int y){
while(y != 0){
int r = x % y;
x = y;
y = r;
}
return x;
}
int lcm(int x, int y){
return x*y/gcd(x, y);
}
int main(){
int x,y;
scanf("%d %d", &x, &y);
printf("%d %d\n", lcm(x, y), gcd(x, y));
return 0;
}
```