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\n", G, L)
	}
}

C++: #include <iostream>

using namespace std;


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

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

void solve()
{
	int m, n;
	while(cin >> m >> n)
	{
		int g = gcd(m, n);
		cout << g << " " <<	lcm(m, n, g) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

C++: #include<iostream>
int GCD(int x,int y){
	while(x%y!=0){
		int z=x%y;
		x=y;
		y=z;
	}
	return y;
}
int main(){
	int a=0,b=0;
	while(std::cin>>a>>b){
		std::cout<<GCD(a,b)<<" "<<a*b/GCD(a,b)<<std::endl;
	}
	std::system("pause");
	return 0;
}

C++: #include<cstdio>
typedef long long lolo;
lolo gcd(lolo a, lolo b){
  if(b == 0)
    return a;
  else
    return gcd(b,a%b);
}
void solve(lolo a, lolo b){
  lolo ans = gcd(a,b);
  printf("%lld %lld\n",ans,a / ans * b);
}
int main(){
  lolo a;
  lolo b;
  while(scanf("%lld %lld",&a,&b) != EOF)
    solve(a,b);
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


#define N 1024

int main()
{
	char buff[N];
	
	while (NULL != fgets(buff, N, stdin))
	{
		int a, b;
		sscanf(buff, "%ld %ld", &a, &b);
		
		int  m, n, k;
		m = a;
		n = b;
		do
		{
			k = m % n;
			m = n;
			n = k;
		} while (0 != k);
		
		printf("%d %d\n", m, a * (b / m));
	}
	return 0;
}

C++: #include <cstdio>

int getGCD(int a, int b)
{
        if (!b) {
                return a;
        }

        return getGCD(b, a % b);
}

int getLCM(int a, int b)
{
        int lcm = a;

        while (lcm % b) {
                lcm+=a;
        }

        return lcm;
}

int main()
{
        int a, b;

        while (scanf("%d %d", &a, &b)) {
                int max = (a > b) ? a : b,
                    min = (a < b) ? a : b;
                printf("%d %d\n", getGCD(max, min), getLCM(max, min));
        }

        return 0;
}

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

void change(long long *a,long long *b);
long long gcd(long long x,long long y);
long long lcm(long long x,long long y);


int main(void){
	long long a, b, gcd1, lcm1;
	while(cin >> a >> b){
		gcd1 = gcd(a,b);
		lcm1 = lcm(a,b);
		
		cout << gcd1 << ' ' << lcm1 << endl;
	}
	return 0;
}

void change(long long *a,long long *b){
	long long temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

long long gcd(long long x,long long y){
	if(x < y)
	change(&x, &y);
	
	while(y){
		x %= y;
		change(&x, &y);
	}
	return x;
}

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

C++: #include <iostream>

int main(void)
{
	uint32_t a = 0;
	uint32_t b = 0;

	while (std::cin >> a >> b)
	{
		uint32_t a2 = a;
		uint32_t b2 = b;
		if (a < b)
		{
			uint32_t tmp = a;
			a = b;
			b = tmp;
		}
		uint32_t r = 0;
		while (r = (a % b))
		{
			if (r == 0)
			{
				break;
			}
			a = b;
			b = r;
		}
		std::cout << b << " " << a2/b*b2 << std::endl;
	}

	return 0;
}

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

int main()
{
	long int a,b,i,k;

	while(cin>>a>>b){
		long int x=1, y=0;	//x最大公約数 y最小公倍数
		long int large ,small;

		//最小公倍数を求める処理
		if(a<b){small=a; large=b;}
		else{small=b; large=a;}
		for(i=large ;y==0 ;i+=large){
			if(i%small==0) y=i;
		}
		
		//最大公約数を求める処理
		long int ans[1000];
		i=2; k=0;
		while(a>=i && b>=i){
			if(a%i==0 && b%i==0){
				ans[k]=i;
				a/=i; b/=i;
				k++;
			}else{
				i++;
			}
		}
		for(i=0 ;i<k ;i++) x*=ans[i];

		cout<<x<<" "<<y<<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int gcd(int a, int b){
    int tmp,q,r;
    if(a<b){
        tmp=b;
        b=a;
        a=tmp;
        }
        while(1){
        q=b/a;
        r=b%a;
        b=a;
        a=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>
#include <algorithm>
using namespace std;
int main(){
	long long a,b,yakuans,baians;
	while(cin>>a>>b){
		long long c;
		c=a*b;
		if(b>a)swap(a,b);
		while(1){
			long long r;
			r=a%b;
			if(a%b==0)break;
			a=b;
			b=r;
		}
		baians=c/b;
		cout<<b<<" "<<baians<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	long a, b, r, c, d;
	long ta, tb;

	scanf("%d %d", &a,& b);
	ta = a;
	tb = b;

	while (1) {
	r = ta % tb;
	if (r == 0) break;
	ta = tb;
	tb = r;
	}
	c = tb;

	d = b * (a  / c);

	printf("%d %d\n", c, d);

	return (0);
}

C++: #include<cstdio>
#include<iostream>
#include <algorithm>

using namespace std;

int main() {
	long a, b;
	while (cin >> a >> b) {

		cout << __gcd(a, b) << " " << a * b / gcd(a, b) << endl;
	}

}

C++: #include <cstdio>
#define ll long long
ll gcb(ll a, ll b) {
    return a ? gcb(b % a, a) : b;
}
ll a, b;
int main() {
    while (~scanf("%lld %lld", &a, &b)) {
        if (a > b) {
            ll t = a;
            a = b;
            b = t;
        }
        ll g = gcb(a, b);
        printf("%lld %lld\n", g, a * b / g);
    }
    return 0;
}

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

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

int main(){
  int a,b;
  while(scanf("%d %d",&a,&b) != EOF)
    {
      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 <iostream>
using namespace std;
int main(void){
    long long int a, b;
    while(cin >> a >> b){
        long long int tmp;
        if(a < b){
            tmp = a;
            a = b;
            b = tmp;
        }

        long long int m = a * b;
        //ユークリッドの互除法を用いて最大公約数を求める
        long long int r = a % b;
        while(r != 0){
            a = b;
            b = r;
            r = a % b;
        }
        long long int gcd = b;

        //続いて、公式を用いて最小公倍数を求める
        long long int lcm = m / gcd;

        cout << gcd << " " << lcm << endl;
    }
}

C++: #include <iostream>

using namespace std;

int gcd(int x, int y) {
	int r;
	if(x == 0 || y == 0) {
		return 0;
	}

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

long long int lcm(int x, int y) {
	if(x == 0 || y == 0) {
		return 0;
	}
	return ((x / gcd(x, y)) * y );
}

int main() {
	int x, y;

	while(cin >> x >> y) {
		if(x > y) {
			cout << gcd(x, y) << " " << lcm(x, y) << endl;
		}
		else {
			cout << gcd(y, x) << " " << lcm(y, x) << endl;
		}
	}
}

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

int main(){
		long long a, b, gcd, lcm;
		while(cin >> a >> b){
				vector<long long> divisor_a;
				vector<long long> divisor_b;
				for(int i = 2; i <= a; i++){
						if(a % i == 0) divisor_a.push_back(i);
				}
				for(int i = 2; i <= b; i++){
						if(b % i == 0) divisor_b.push_back(i);
				}
				for(int i = 0; i < divisor_a.size(); i++){
						for(int j = 0; j < divisor_b.size(); j++){
								if(divisor_a[i] == divisor_b[j]) gcd = divisor_a[i];
						}
				}
				lcm = a / gcd * b;
				cout << gcd << " " << lcm << endl;
		}
		return 0;
}