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>
using namespace std;
int main()
{int a, b, c = 0;while (cin >> a, cin >> b){for (int i = 1; i <= a, i <= b; i++){if (a % i == 0 && b % i == 0){c = i;}}cout << c << " " << a*b / c << endl;}return 0;}

C++: // B.cpp

#include <iostream>

using namespace std;

int gcd(int, int);
int lcm(int, int);

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

int gcd(int a, int b) {
	int max, min, res;
	
	res = 1;
	
	if(a > b){
		max = a, min = b;
	}
	if(a <= b){
		max = b, min = a;
	}
	if(min == 0) return max;
	while(res) {
		res = max % min;
		max = min;
		min = res;
	}
	return max;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

C++: #include <iostream>

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

int main()
{ 
	int a, b;

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

	return 0;
}

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


 
int main(){
	int in[2],a,b,ans[2],i = 2;
	while(cin >> in[0] >> in[1]){
		a = in[0];
		b = in[1];
		if(a >= b){
			while(a >= 0){
				if(in[0] % a == 0 and in[1] % a == 0){
					ans[0] = a;
					break;
				}
				a--;
			}
		}else if(b >= a){
			while(b >= 0){
				if(in[0] % b == 0 and in[1] % b == 0){
					ans[0] = b;
					break;
				}
				b--;
			}
		}else{
			ans[0] = 1;
		}
		cout << ans[0] << endl;
		a = in[0];
		b = in[1];

		ans[1] = 1;
		while(i <= a or i <= b){
			if(a % i == 0 and b % i == 0){
				a = a / i;
				b = b / i;
				ans[1] = ans[1]*i;
				i = 1;
			}
			i++;
		}
		ans[1] = ans[1]*a*b;
		cout << ans[1] << endl;
		
	}
}

C++: /********************************************************************
 * ??£?????´??° a,b ?????\?????????a ??¨ b ????????§??¬?´???°??¨????°???¬?????°???????????????
 * ????????°?????????????????????????????????
 ********************************************************************/
#include <iostream>
//#include <cstring>
typedef struct _input_values {
    int a;
    int b;
} INPUT_VALUES;

typedef struct _input_values_list {
    INPUT_VALUES sList[10000];
    int effectCount;
} INPUT_VALUES_LIST;

int gcd( int a, int b );    // ?????§??¬?´???°????±???????
int lcm( int a, int b, int g );    // ????°???¬?????°????±???????

using namespace std;

int main()
{
    int i = 0;
    int tA = 0, tB = 0;
    int g = 0, l = 0;
    INPUT_VALUES_LIST values = {0};

    //memset( &values, 0, sizeof(values) );

    while( cin >> tA >> tB ) {
        values.sList[values.effectCount].a = tA;
        values.sList[values.effectCount].b = tB;
        values.effectCount++;
    }

    for ( i = 0; i < values.effectCount; i++ ) {
        g = gcd( values.sList[i].a, values.sList[i].b );
        l = lcm( values.sList[i].a, values.sList[i].b, g );
        cout << g << " " << l << endl;
    }

    return 0;
}

/*  @brief  ?????§??¬?´???°????±???????
 *  @param  [i] a   ???????????????
 *  @param  [i] b   ???????????????
 *  @retval ?????§??¬?´???°
 */
int gcd( int a, int b )
{
    int ret = 0;

    if ( 0 == a || 0 == b ) {
        return 0;
    }

    if ( a != b ) {
        if ( a > b ) {
            a = a - b;
        } else {
            b = b - a;
        }
    } else {
        return a;
    }

    ret = gcd( a, b );

    return ret;
}

/*  @brief  ????°???¬?????°????±???????
 *  @param  [i] ???????????????
 *  @param  [i] ???????????????
 *  @param  [i] ?????§??¬?´???°
 *  @retval ????°???¬?????°
 */
int lcm( int a, int b, int g )
{
    if ( 0 == a || 0 == b ) {
        return 0;
    }

    return ( a * b / g );
}

C++: #include<iostream>
using namespace std;
int GCD(int n,int m){
  if(n<m){
    int t;
    t = m;
    m = n;
    n = t;
  }
  int i;
  while(n%m != 0){
    i = n%m;
    n = m;
    m = i;
  }
  return m;
    
}
int main(){
  int n,m,i=0,a[50],b[50];
  while(cin >> n >> m){
    a[i] = GCD(n,m);
    b[i] = m/GCD(n,m)*n;
    i++;
    n = 0;
    m = 0;
  }
  for(n=0;n<i;n++) cout << a[n] << " " << b[n] << endl;
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#define LL long long

LL gcd(LL a, LL b) { return b ? gcd(b, a%b) : a; }

int main() {
	LL A, B;
	while (std::cin >> A >> B) {
		if (A < B)std::swap(A, B);
		LL g = gcd(A, B);
		std::cout << g << " " << (A*B) / g << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int a,b,gcda,gcdb,c;
        while(scanf("%d %d",&a,&b)!=EOF){
                if(a<b){
                        swap(a,b);
                }
                gcda=a;
                gcdb=b;
                while(gcda%gcdb){
                        c=gcdb;
                        gcdb=gcda%gcdb;
                        gcda=gcdb;
                }
                printf("%d %d\n",gcdb,(a*b)/gcdb);
        }
        return 0;
}

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

long long gcd(long long a,long long b){
    if(b>a){long long t=a;a=b;b=t;}
    while(true){
        if(a%b==0){return b;}
        else{a=a%b;}
        if(b%a==0){return a;}
        else{b=b%a;}
        }
}

long long lcm(long long a,long long b){
    return a*b/gcd(a,b);
}

int main ()
{
    long long x,y;
    while(cin>>x>>y){
    cout<<gcd(x,y)<<' '<<lcm(x,y)<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int gcd(int x,int y);
int lcm(int x,int y);

int main(){
  int a,b;

  cin >> a >> b;

  cout << gcd(a,b) <<" "<<lcm(a,b)<<endl;

  return 0;
}

int gcd(int x,int y){
  int z;
  while(y != 0){
  z = x%y; 
  x = y;
  y = z;
  }
  return x;
}

int lcm(int x,int y){

  return x/gcd(x,y)*y;

}

C++: #include<stdio.h>
int gcd(int x,int y){
    int r,m;
    if(x < y){
        m=x;
        x=y;
        y=m;
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main()
{
    unsigned long long int a,b,x,n;
    while(scanf("%lld%lld",&a,&b)!=EOF){
        x=gcd(a,b);
        printf("%lld ",x);
        n=a/x*b;
        printf("%lld\n",n);
    }
    return 0;
}

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

int main(){
  int a,b,ky,kb,t,k;

  for(int n=0;n<50;n++){
    cin>>a;
    cin>>b;
    t=1;
    for(int i=1;i<2000000000;i++){
      if(a%i==0&&b%i==0){
        a=a/i;
        b=b/i;
        t=i*t;
      }
    }
    k=t*a*b;
    cout<<t<<" "<<k;
  }
  return 0;
}

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

int main(){
	long long a,b,GCD,LCM,x,a2,b2;
	while(cin>>a>>b){
	a2=a;
	b2=b;
	while(a!=b){
		if(a>b){
			x=a-b;
			a=b;
			b=x;
		}
		else if(b>a){
			x=b-a;
			b=a;
			a=x;
		}
	}
	GCD=a;
	LCM=a2*b2/a;

	cout<<GCD<<" "<<LCM<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int a,b;
	int miner,maxer;
	while(cin >> a >> b){
		int a2=a,b2=b;
		while(max(a2,b2)%min(a2,b2)!=0){
			if(a2>b2)
			a2=a2-b2;
			else
			b2=b2-a2;
		}
		miner =min(a2,b2)
		cout << miner << endl;
		cout << a*b/miner << endl;
	}
	return 0;
}