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>
#include<cstdio>
using namespace std;
int main(){
	long long a,b,s,m,ta,tb,tmp;
	while(cin>>a>>b){
	ta=a,tb=b;
	s=1,m=1;
	if(a<b)swap(a,b);
	else 
	while(true){
		tmp=a;
		a=b;
		b=tmp%a;
		if(a%b==0){
			m=b;
			break;
		}
		if(a<b){
		//cout<<a<<" "<<b<<endl;
		m=1;
		break;
		}
		s=(ta*tb)/m;
		cout<<m<<" "<<s<<endl;
	}
	}
}

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

int main() {
  long long a, b;
  while (cin >> a >> b) {
    long long g = __gcd(a, b);
    cout << g << " " << a * b / g << endl;
  }
}

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

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

int main()
{
  int a,b;
  int g;
  long int l;
  while(cin >> a >> b){
  
    if(a>b) g=gcd(a,b);
    else if(a<b) g=gcd(b,a);
    else g=a;

    l=(long int)a*b/g;
    cout << g << " " << l << endl;
  }

  return 0;
}

C++: #include <cstdio>

int main(){
    long long int m, n, gcd, lcm, temp;
    while(scanf("%lld %lld", &m, &n) == 2){
        lcm = n * m;
        if( m < n ){
            temp = m;
            m = n;
            n = temp;
        }
       for(;;){
           if(n == 0) break;
           temp = n;
           n = m % n;
           m = temp;
       }
       gcd = m;
       lcm = lcm / gcd;
       printf("%lld %lld\n", gcd, lcm);
    }
    return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005

long int gcd(int a, int b) {
	if (a < 0) a *= -1;
	if (b < 0) b *= -1;
	if (a < b) {
		int t = a;
		a = b; 
		b = t;
	}
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

C++: #include<iostream>
using namespace std;
int main(){
int a,b,g,x,y,L,i=0;
while(i>50){
cin>>a>>b;
if(a==0 || b==0){cout<<0<<" "<<0<<endl;}
x=a;y=b;
while(1){
  if(x<y){y-x;}
  else if(x>y){x-y;}
  else if(x==y){g=x;break;}
}
L=(a*b)/g;
if(a!=0 || b!=0){cout<<g<<" "<<L<<endl;}
  ++i;
}
  return 0;
}

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

template<typename T>
T gcd(T p, T q)
{
	while(q != 0)
	{
		T temp = p % q;
		p = q;
		q = temp;
	}

	return p;
}

template<typename T>
T lcm(T p, T q)
{
	return p / gcd(p, q) * q;
}

int main()
{
	unsigned long long a, b;
	while(cin >> a >> b)
		cout << gcd(a, b) << " " << lcm(a, b) << endl;

	return 0;
}

C++: #include <iostream>
using namespace std;
int num[2];
inline int gcd(int a, int b)
{
	return num[0] = b == 0 ? a : gcd(b, a%b);
}
inline int* lcm(int a, int b)
{
	num[1] = a/gcd(a, b)*b;
	return num;
}
int main()
{
	int a, b;
	while(scanf("%d%d", &a, &b) != EOF)
	{
		if(a < b) swap(a, b);
		lcm(a, b);
		printf("%d %d\n", num[0], num[1]);
	}
	return 0;
}

C++: /*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005
 */
#include <iostream>
#include <sstream>

#define N 2

using namespace	std;

long
gcd(long a, long b)
{
	return a % b == 0 ? b : gcd(b, a % b);
}
long
lcm(long a, long b)
{
	long t = gcd(a, b);
	return t ? (a * b) / t : 0;
}
int
main()
{
	string line;
	while (getline(cin, line)) {
		istringstream iss(line);
		long a, b;
		iss >> a >> b;
		cout << gcd(a, b) << ' ' << lcm(a, b) << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){

long long int a,b,A,B;

while(cin>>a>>b){
 A=a;B=b;
 while (b)
      {
	int tmp = a % b;
	a = b;
	b = tmp;
      }

b=A*B/a;
cout<<a<<" "<<b<<endl;
}
return 0;
}

C++: #include <iostream>

using namespace std;
int f(int a,int b){
     int n;
     n=a%b;
   return n;
}
int main(){
    int a,b,c,d,x,y,z;
    while(cin>>x>>y){
    a=x;
    b=y;
    c=1;
      for(d=0;c>0;d++){
         c=f(a,b);
         a=b;
         b=c;
    }
    z=x*y/a;
    cout<<a<<" "<<z<<endl;
         }
         return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a,b,g,x,y,L,i;
while(i>50){
cin>>a>>b;
a=x;b=y;
while(1){
  if(x<y){y-x;}
  else if(x>y){x-y;}
  else if(x==y){x=g;break;}
}
L=(a*b)/g;
  cout<<g<<" "<<L<<endl;
  ++i;
}
  return 0;
}

C++: 

#include <stdio.h>
  
int main(){
   
    int buf1[50],buf2[50];
   
    int k = 0;
    while( scanf( "%d %d",&buf1[k],&buf2[k] ) != EOF ) k++;
   
    for( int i = 0;i < k;i++ ){
        int b1 = buf1[i],b2 = buf2[i];
        int m,n;
        if( b1< b2 ){
            m = b2,n = b1;
        } else if( b1 > b2 ){
            m =  b1,n = b2;
        } else {
            n = 0;
            m = b1;
        }
        
        while( n != 0 ){
            int buf = n;
            n = m % n;
            m = buf;
        }
        printf( "%d\n",m );

        while( b1 != b2 ){
            if( b1 < b2 ) b1 += buf1[i];
            else             b2 += buf2[i];
        }
        printf( "%d\n",b1 );
    }
    return 0;
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<cstring>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){
    ll a,b;
    while(cin>>a){
        cin>>b;
        if(b>a)swap(b,a);
        ll aa=a,bb=b;
        ll o,p,q;
        while(bb!=0){
            o=bb;
            p=aa%bb;
            aa=bb;bb=p;
        }
        ll i=1;
        while(true){
            i++;
            ll ao=a*i;
            if(ao%b==0){
                q=ao;
                break;
            }
        }
        cout<<o<<" "<<q<<endl;
    }
    
    
    
    
    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
  return a / gcd(a, b) * b;
}
int a,b;

int main(){
    while(cin>>a>>b){
        cout<<gcd(a,b)<<" "<<lcm(a,b);
    }
}

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

//最小公約数
int gcd(ll a,ll b){
    if( a==0 || b==0)
          return 0;
            while(a != b){
                  if(a > b) a= a-b;
                      else b=b-a;
                        }
                          return a;
}

//最小公倍数
int lcm(ll m,ll n){
    if(m==0 || n==0)
          return 0;
            return m/gcd(m,n)*n;
}

int main(){
  ll a,b;
 while( cin >> a>> b){
  cout << gcd(a,b) << " "<<lcm(a,b) << endl;
 }
}