Advertisement
Imran_Mohammed

GCD__LCM

Feb 14th, 2021
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main ()
  5.  {
  6.      int a,b;
  7.      cin >> a >> b;
  8.  
  9.      //GCD : Greatest Common Divisor
  10.      cout << __gcd(a , b) << endl;//12
  11.  
  12.      //LCM : Least Common Divisor
  13.      int lcm = (a* (b/__gcd(a,b) ) );
  14.      cout << lcm << endl;//24
  15.  
  16.     return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement