Go: package main

import "fmt"

func gcd(x, y int64) int64 {
	for y != 0 {
		r := x % y
		x = y
		y = r
	}
	return x
}

func lcm(x, y int64) int64 {
	return x / gcd(x, y) * y
}

func main() {
	for {
		var a, b int64

		fmt.Scanf("%d %d", &a, &b)

		if a == 0 && b == 0 {
			break
		}

		fmt.Printf("%d %d\n", gcd(a, b), lcm(a, b))
	}
}

C++: #include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;

int Greatest_Common_Divisor(int a, int b) {

	while (a != 0 && b != 0) {
		if (a > b) {
			a = a - b;
		}
		else {
			b = b - a;
		}
	}
	return(a + b);
}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	unsigned int a = 0, b = 0;
	std::vector<unsigned int> GCD;
	std::vector<unsigned long long> LCM;

	while (std::cin >> a) {
		std::cin >> b;
		GCD.push_back(Greatest_Common_Divisor(a, b));
		unsigned long long c = a*b;
		LCM.push_back(c / GCD.back());
	}

	for (unsigned int i = 0; i < GCD.size(); i++) {
		std::cout << GCD[i] << " " << LCM[i] << std::endl;
	}

	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

C++: #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a, b;
    while(cin >> a >> b){
    cout << __gcd(a, b) <<  " " << lcm(a, b) << endl;
    }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <utility>
typedef unsigned long ul;

using namespace std;

int gcd(ul a, ul b);

int main(){
	ul a, b, gcd_num;
	while(cin >> a >> b){
		if(a < b){
			swap(a,b);
		}
		gcd_num = gcd(a, b);
		cout << gcd_num << " " << (a*b)/gcd_num << endl;
	}
}

int gcd(ul a, ul b){
	ul r;
	while((r = a % b) != 0){
		a = b;
		b = r;
	}
	return b;
}

C++: #include<iostream>
#include<algorithm>
typedef unsigned long long ll;
using namespace std;
ll gcd(ll a,ll b)
{
    if(a<b) swap(a,b);
    if(b==0) return a;
    else if(a&1&&b&1) return gcd(b,(a-b)>>1);
    else if(a&1&&b) return gcd(a,b>>1);
    else if(a&&b&1) return gcd(a>>1,b);
    else return 2*gcd(a>>1,b>>1);
}
int main(void)
{
    ll a,b;
    while(cin>>a>>b) {
        cout<<gcd(a,b)<<' '<<a*b/gcd(a,b)<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

int getLCM(int, int);
int getGCD(int, int, int);

int main(int argc, char *argv[]) {
  int x, y;
  vector<int> result;

  while (cin >> x >> y) {
    int lcm = getLCM(x, y);
    int gcd = getGCD(x, y, lcm);
    result.push_back(lcm);
    result.push_back(gcd);
  }
  for (int i = 0; i < result.size()/2; i++)
    cout << result[i*2] << ' ' << result[i*2+1] << endl;
  return 0;
}

int getLCM(int x, int y) {
  int tmp;

  if (x < y) {
    tmp = y;
    y = x; 
    x = tmp;
  }
  while (x % y != 0) {
    tmp = x % y;
    x = y;
    y = tmp;
  }
  return y;
}


int getGCD(int x, int y, int lcm) {
  x /= lcm;
  y /= lcm;
  return x * y * lcm;
}

C++: #include <cstdio>
using namespace std;

int get_gcd(int a, int b) {
  int r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int a, b;
  while (~scanf("%d %d", &a, &b)) {
    int gcd = get_gcd(a, b);
    int lcm = a / gcd * b;
    printf("%d %d\n", gcd, lcm);
  }
}

C++: #include <iostream>
using namespace std;

int SKB(double x, double y, double w){
	double n = (x*y)/w;
	return (int)n;
}

int YUK(int x, int y){
	int c;
		c = x%y;
		if(c == 0){
			return y;
		}else{
			return YUK(y,c);
		}
}

int main(){
	int a, b;

	while( cin >> a >> b ){
		int d;
		if(a >= b){
			d = YUK(a,b);
			cout << d << ' ' << SKB(a,b,d);

		}else{
			d = YUK(b,a);
			cout << d << ' ' << SKB(a,b,d);
		}
		cout << '\n';
	}

	return 0;
}

C++: #include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
    int a,b;
    
    while(cin >> a >> b){
        
        int g,l;
        int aa,bb;
        g = l = 1;
        
        /* ?????§??¬?´???° */
        aa = a;
        bb = b;
        while(true){
            int tmp = 0;
            
            if(aa % 3 == 0 && bb % 3 == 0){
                aa /= 3;
                bb /= 3;
                tmp = 3;
            }
            else if(aa % 2 == 0 && bb % 2 == 0){
                aa /= 2;
                bb /= 2;
                tmp = 2;
            }
            
            if(g == 0){
                g = tmp;
            }
            else{
                g *= tmp;
            }
            
            if(aa <= 3 || bb <= 3){
                break;
            }
            
            if((aa % 2 != 0 && bb % 2 != 0) ||
               (aa % 3 != 0 && bb % 3 != 0)){
                break;
            }
        }
        
        /* ????°???¬?????° */
        aa = a;
        bb = b;
        while(true){
            int tmp = 0;
            
            if(aa % 3 == 0 && bb % 3 == 0){
                aa /= 3;
                bb /= 3;
                tmp = 3;
            }
            else if(aa % 2 == 0 && bb % 2 == 0){
                aa /= 2;
                bb /= 2;
                tmp = 2;
            }
            
            if(g == 0){
                l = tmp;
            }
            else{
                l *= tmp;
            }
            
            if(aa <= 3 || bb <= 3){
                l *= aa;
                l *= bb;
                break;
            }
            
            if((aa % 2 != 0 && bb % 2 != 0) ||
               (aa % 3 != 0 && bb % 3 != 0)){
                l *= a;
                l *= b;
                break;
            }
        }
        
    }
    
    return 0;
}