Advertisement
enigmjoe

Code and Debug 2.0

Oct 15th, 2022 (edited)
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void hcf(int a , int b){
  5.     ans = a;
  6.     while (ans > 0) {
  7.         if (a % ans == 0 && b % ans == 0) {
  8.             break;
  9.         }
  10.         ans++;
  11.     }
  12.     return ans;
  13. }
  14.  
  15. void lcm(int a , int b){
  16.     System.out.println(a * b / hcf(a , b));
  17. }
  18.  
  19. int main(){
  20.     int t;
  21.     cin >> t;
  22.     while(t--){
  23.         int a , b;
  24.         cin >> a >> b;
  25.         cout < hcf(a , b) < " ";
  26.         lcm(b , a);
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement