Go: package main

import "fmt"

func GCM(a, b int) int {
	if a < b {
		a, b = b, a
	}
	if b == 0 {
		return a
	}
	return GCM(b, a % b)
}

func LCM(a, b int) int {
	return a*b/GCM(a, b)
}

func main() {

	for {
		var a, b int
		var G, L int
		fmt.Scanf("%d %d", &a, &b)
		if a == 0 {
			break
		}
		G = GCM(a, b)
		L = LCM(a, b)
		fmt.Printf("%d %d", G, L)
	}
}

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

int main(){

	long long a = 0, b = 0;

	while (cin >> a >> b){
		int gcd = 0;
		long long lcm = 0;
		int r = 0;
		int temp_a = 0, temp_b = 0;
		temp_a = a;
		temp_b = b;
		while ((max(temp_a, temp_b) % min(temp_a, temp_b)) != 0){
			r = (max(temp_a, temp_b) % min(temp_a, temp_b));
			temp_a = temp_b;
			temp_b = r;
		}
		gcd = temp_b;
		cout << gcd << " ";

		lcm = a * b / gcd;
		cout << lcm << endl;

	}

	//getchar();

	return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;
 
 long long int gcd(long long int p,long long int q)
 {
   return q==0 ? p:gcd(q,p%q);     
 }

 int main()
 {
   long long int n,m;
   while(cin>>n>>m)
   {
     long long kk=gcd(n,m);
     cout<<kk<<" "<<n/kk*m<<endl;             
   }
   //while(1);      
   return 0;    
 }

C++: #include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c, d;
	while(cin >> a >> b) {
		c = a;
		d = b;
		while (1) {
			if(a == 0) {
			cout << 0 << " " << 0 << endl;
			break;
			}
			if ((max(a, b) % min(a, b)) == 0) {
				cout << min(a, b);
				break;
			}else if(a > b) {
				a  = a%b;
			}else b = b%a;
		}
		if(a != 0) { 
		cout << " " << c / min(a,b) * d << endl;
		}
	}

	return 0;
}

C++: #include<iostream>

int gcd(int a, int b){
  int k;
  if(b>a){
    k=b;
    b=a;
    a=k;
  }
  while(k!=0){
    k = a % b;
    a = b;
    b = k;
  }
  return a;
}

int main(){
  int a, b;

  while(std::cin >> a >> b){
    std::cout << a*b/gcd(a,b) << " " << gcd(a,b) << std::endl;
  }
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int d(int n,int m)
{
    int t;
    while(m!=0)
    {
        if(n<m) {t=n;n=m;m=t;}
        t=m;
        m=n%m;
        n=t;
    }
    return n;
}
int main()
{
    int t,n,m;
    while(1)
    {
        cin>>n>>m;
        cout<<t<<" "<<n*(m/t)<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

long GCD(long x, long y) {
    if (x % y == 0) return y;
    else return GCD(y, x % y);
}

int main() {
    long a, b;
    while (cin >> a >> b) {
    long GCD_a, LCM_a;
    GCD_a = GCD(a, b);
    LCM_a = a * b / GCD(a, b);
    cout << GCD_a << ' ' << LCM_a << endl;
    }
}

C++: /*
 * hujx.cpp
 *
 *  Created on: 2015年5月21日
 *      Author: dell
 */
#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
#include<set>
#include<bitset>
//#define ONLINE_JUDGE
#define eps 1e-5
#define INF 0x7fffffff
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,num) scanf("%d%d%d",&a,&b,&num)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll long long
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
//#pragma comment(linker,"/STACK:1024000000,1024000000")
int n,m,c;
#define N 210
#define M 100010
#define Mod 1000000000
#define p(x,y) make_pair(x,y)
const int MAX_len=550;
int main(){
    ll a,b;
    while(scanf("%lld%lld",&a,&b)!=EOF){
    	ll GCD = gcd(a,b);
    	ll LCM = a/GCD*b;
    	printf("%lld %lld\n",GCD,LCM);
    }
    return 0;
}

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

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

int main(void){
    int a, b;
    while(cin >> a >> b) {
      int lcm = a/gcd(a,b)*b;
      cout << gcd(a,b) << " " << lcm << endl;
    }
    return 0;
}

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

TYPE gcd(TYPE a,TYPE b){
  if( !b ) return a;
  return gcd(b, a%b);
}
int main(){
  TYPE a,b;
  while(cin>>a>>b){
    TYPE g = gcd(a,b);
    TYPE l = a/g*b;
    cout << g << " " << l << endl;
  }
}

C++: #include<stdio.h>
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
	int  a, b, a1, b1, c, g;
	long l;
	cin >> a >> b;
	a1 = a;
	b1 = b;
	while (cin>>a>>b)
	{
		if (a == 0 || b == 0)
		{
			break;
		}


		while (1)
		{
			c = abs(a - b);
			if (c == 0)
			{
				break;
			}

			if (a > b)
			{
				a = c;
				g = c;
			}
			else if (a < b)
			{
				b = c;
				g = c;
			}
		}
		l = (a1 / g)*b1;
		cout << g << " " << l << endl;
		
		a1 = a; b1 = b;
	}
}

C++: #include<iostream>
int e(int a,int b){
	if(a<b)a^=b^=a^=b;
	return (a%=b)?e(b,a):b;
}
int f(int a,int b,int c,int d){
	if(a<b)a^=b^=a^=b;
	for(;a>b;)b+=d;
	return a-b?f(b,a,d,c):a;
}
int main(){
	for(int a,b,s;s=!(std::cin>>a>>b).eof();s&&printf("%d %d\n",e(a,b),f(a,b,a,b)))
		;
}

C++: #include<cstdio>
#include<iostream>
class GCDandLCM{
    public:
        void solve(int a,int b){
            int big=a,small=b;
            if(a<b){ 
                big=b;
                small=a;
                int tmp=a;
                a=b;
                b=tmp;
            }
            while(big%small!=0){ 
                int tmp=big%small;
                big=small;
                small=tmp;
            }
            printf("%d %d\n",small,(a*b)/small);
        }
};
int main(){ 
    GCDandLCM inst;
    int a,b;
    while(scanf("%d%d",&a,&b)){ 
        inst.solve(a,b);
    }
}

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

int A[60],B[60];

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

int main(){
	int N;
	for(int i=1;i<=50;i++){
		cin>>A[i]>>B[i];
		if(cin.eof()){
			N=i-1;
			break;
		}
	}
	int res[2];
	for(int i=1;i<=N;i++){
		res[0]=gcd(A[i],B[i]);
		res[1]=A[i]/res[0]*B[i];
		cout<<res[0]<<" "<<res[1]<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int a,b,c,max=0,min=0,bet,les,ch1=0,ch2=0;
  vector<int> ayaku;
  vector<int> byaku;
  while(cin>>a>>b){
    bet=a%b;
    if(bet!=0)
      les=b%bet;
    if(bet==0)
      max=b;
    else if(les==0)
      max=bet;
    else{
      for(;;){
	ch1=bet%les;
	if(ch1==0){
	  max=les;
	  break;
	}
	bet=les;
	les=ch1;
      }
    }
    min=(a/max)*b;
    cout<<max<<" "<<min<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int a, b,A, B;
	while (cin >> a >> b)
	{
		int c = a;
		int d = b;
		if (a <= b)
		{
			while (a != 0)
			{
				int r = b%a;
				b = a;
				a = r;
			}
			A = b;
		}
		else
		{
			while (b != 0)
			{
				int r = a%b;
				a = b;
				b = r;
			}
			A = a;
		}
		B = c / A*d;
		cout << A << " " << B << endl;
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

long long gcd(long long a, long long b)
{
  if (b == 0) {return a;}
  return gcd(b, a % b);
}

int main()
{
  long long a, b;
  while (scanf(" %lld %lld ", &a, &b) == 2) {
    printf("%lld %lld\n", gcd(a, b), a * b / gcd(a, b));
  }
}