Solutions of GCD and LCM - MarisaOJ: Marisa Online Judge

Solutions of GCD and LCM

Select solution language

Write solution here.


User Avatar kunnan9999    Created at    0 likes

We calculate the LCM and GCD of a and b In C++, we don't have LCM so we use a * b / GCD(a, b) Code: ``` #include<bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; //Calculate GCD and LCM int gcd = __gcd(a, b); int lcm = a * b / __gcd(a, b); //Then print GCD and LCM cout << gcd << " " << lcm; return 0; } ```