Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void hcf(int a , int b){
- ans = a;
- while (ans > 0) {
- if (a % ans == 0 && b % ans == 0) {
- break;
- }
- ans++;
- }
- return ans;
- }
- void lcm(int a , int b){
- System.out.println(a * b / hcf(a , b));
- }
- int main(){
- int t;
- cin >> t;
- while(t--){
- int a , b;
- cin >> a >> b;
- cout < hcf(a , b) < " ";
- lcm(b , a);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement