Advertisement
LEGEND2004

gcd lcm

Feb 12th, 2024 (edited)
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. #define fastio ios_base::sync_with_stdio(0); cin.tie(0)
  6. const int N = 2e5 + 5;
  7.  
  8. int gcd(int a , int b){
  9.     if(b == 0)  return a;
  10.     return gcd(b , a % b);
  11. }
  12.  
  13. int lcm(int a , int b){
  14.     return a / gcd(a , b) * b;
  15. }
  16.  
  17.  
  18. signed main()
  19. {
  20.     fastio;
  21.  
  22.     int a , b;
  23.     cin >> a >> b;
  24.     cout << gcd(a , b) << ' ' << lcm(a , b) << '\n';
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement