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 <stdio.h>

int main() {
  int a, b, i, j, x, y;
  while(scanf("%d %d", &a, &b) != EOF) {
    if(a > b) j = b;
    else      j = a;
    x = 0;
    for(i = j; i > 0; i--) {
      if(a % i == 0 && b % i == 0) {
	x = i;
	break;
      }
    }

    if(b > a) j = b;
    else      j = a;
    y = 0;
    for(i = j; i <= 2000000000; i++) {
      if(i % a == 0 && i % b == 0) {
	y = i;
	break;
      }
    }

    printf("%d %d\n", x, y);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
  while (y != 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}

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

C++: #include <iostream>
using namespace std;
int main(){
    long int a,b,gcd=0,lcm=0,min=0;
    cin>>a>>b;
    if(b>a)min=a;
    else min=b;
    
    for(long int k=min;k>=1;k--){
        if(a%k==0&&b%k==0) {
            lcm=k;
            break;
        }
    }
    
   gcd=a*b/lcm;
    
    cout<<lcm<<" "<<gcd<<endl;
    
}

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

long func(long p, long q);
// int lcm(long p, long q);

int main() {
	long a, b;
	while(cin >> a >> b && a != EOF) {
		long gcd = func(a, b);
		long lcm = a / gcd * b;
		
		cout << gcd << ' ' << lcm << endl;
	}
}

long func(long p, long q) {
	long R = p % q;
	return (R==0? q : func(q,R));
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a;
	while(cin>>a){
		auto b=in();

		out(gcd(a,b),lcm(a,b));
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

long long gcd(int x, int y)
{
  return y?gcd(y, x%y):x;
}

long long lcm(int x, int y)
{
  return x/gcd(x, y)*y;
}

int main()
{
  long long a, b;
  while(scanf("%lld%lld", &a, &b) != -1){
    if(b > a){
      a += b;
      b = a - b;
      a -= b;
    }
    printf("%lld %lld\n", gcd(a, b), lcm(a, b));
  }
  return 0;
}

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

C++: #include <iostream>

using namespace std;

int main(){

	int a,b,c,d;

	while(cin>>a>>b){
		c=a;
		d=b;
		while(1){
			if(c>d)c=c-d;
			cout<<c<<" "<<d<<endl;
			if(c<d)d=d-c;
			
			cout<<c<<" "<<d<<endl;
			if(c==d){
				cout<<c<<" "<<a*b/c<<endl;
				;break;}
		}}
		


return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
long long a,b;
long long GCD(long long x,long long y)
{
	if(x%y==0)return y;
	else return GCD(y,x%y);
}
int main()
{
	while(cin>>a>>b)
	{
		cout<<GCD(a,b)<<" "<<a/GCD(a,b)*b<<endl;	
	}
}

C++: #include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

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

int main(){
  int a, b;

  while(cin >> a >> b){

    int g = gcd(a, b);

    int lcm = a * (b / g);

    cout << g << " " << lcm << endl;
  }

  return 0;
}

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

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	
	int n[50]={0};
	int i=0;
	while(cin>>n[i++]);
	int nn=i-1;
	int gcd=0,lcm=0,a=0,b=0;
	for(int j=0;j<nn;j+=2){
		for(int k=1;k<n[j];k++){
			if(n[j]%k+n[j+1]%k==0)gcd=k;
		}
		a=n[j]/gcd,b=n[j+1]/gcd;
		cout<<gcd<<" "<<gcd*a*b<<endl;
	}
	return 0;
}

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
long long int gcd(long long int a,long long int b) {
  if (a % b == 0) return b;
  else return gcd(b, a % b);
}

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

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

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

int gcd(int a, int b)
{
    int i;
    if (b > a){
        int j = a;
        a = b;
        b = j;
    }
	for (i = a; i >= 1; i--){
		if (a % i == 0)
			if( b % i == 0)
				return i;
	}
}


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

C++: #include <iostream>
using namespace std;
int LCM(int a, int b);
long GCD(int a, int b, int ans1);

int main(){
    int a,b;
    while(cin >> a >> b){
        int ans1 = LCM(a,b);
        long ans2 = GCD(a,b,ans1);
        cout << ans1 << " " << ans2 << endl;
    }
}

int LCM(int a, int b){
    while(1){
        if(a % b == 0) break;
        b = a % b;
        a = b;
    }
    
    return b;
}

long GCD(int a, int b, int ans1){
    double ans = a * b / ans1;
    return (long)ans;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b) {
		for (int i = min(a,b); i > 0; i--)
		{
			if (a%i == 0 && b%i == 0)
			{
				cout << i << " ";
				goto Cs;
			}
		}
		Cs:
		for (int i = max(a,b); ; i++)
		{
			if (i%a == 0 && i%b == 0)
			{
				cout << i << endl;
				goto Cpp;
			}
		}
	Cpp:
		for (int i = 0; i < 0; i++){}
	}
}