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>
#include<stdio.h>
#pragma warning(disable : 4996)
using namespace std;
typedef long long ll;
ll N, M;
ll GCD(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	else {
		return GCD(b, a%b);
	}
}
int main() {
	while (scanf("%d%d",&N,&M)!=EOF)
	{
		int ans =GCD(N, M);
		cout << ans << " " << N * M / ans<<endl;
	}
	
	return 0;
}

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;
	}
	getchar();
	getchar();
	return 0;
}

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

int main(){
	long int ggd[200],num1,num2,lcm[200];
	int a,b;
	int i=0;
	
	while(cin >> a >> b){
		num1 = a;
		num2 = b;
	
		if( a<b ){
			num2 = a;
			num1 = b;
		}
		
		while( (ggd[i]=num1%num2) != 0){
			num1 = num2;
			num2 = ggd[i];
		}
		ggd[i] = num2;
		lcm[i] = a / ggd[i] * b;
		i++;
	}
	
	for(int j=0; j<i; j++)
		cout << ggd[j] <<" "<< lcm[j] << "\n";
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>

using namespace std;
int main() {
	long long int n, m,nn,mm;
	while (cin >> n >> m) {
		nn = n; mm = m;

		if (nn < mm) {
			int swap = nn;
			nn = mm;
			mm = swap;
		}

		int k;
		k = nn%mm;

		while (k != 0) {
			nn == mm;
			mm = k;
			k = nn%mm;
		}
		cout << mm << " ";

		int countn = 1, countm = 1;

		while (1) {
			if (n*countn < m*countm) {
				countn++;
				if (n*countn == m*countm) {
					cout << n*countn << endl;
					break;
				}
			}
			else if (n*countn > m*countm) {
				countm++;
				if (n*countn == m*countm) {
					cout << n*countn << endl;
					break;
				}
			}
			else {
				cout << n*countn << endl;
				break;
			}
		}
	}
	
	
	return 0;
}

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

long GCD(long, long);
long LCM(long, long);

int main()
{
    long a,b;
    while(std::cin >> a >> b)
    {
        if(a < b)
        {
            std::swap(a,b);
        }
        
        std::cout << GCD(a,b) << " ";
        std::cout << LCM(a,b) << std::endl;
    }
    return 0;
}

long GCD(long a, long b)
{
    if(a == 0 || b == 0) return 0;
    long r = a % b;
    if(r == 0) return b;
    return GCD(b,r);
}

long LCM(long a, long b)
{
    if(a == 0 || b == 0) return 0;
    return (a * b / GCD(a,b));
}

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


using namespace std;

int GCD(int a, int b);

int main()
{
  int a,b;
  while(cin >> a >> b)
  {
    if(a>b)
        swap(a,b);
    int x = GCD(a, b);
    cout << x << " " << (a/x)*b << endl;
  }
   return 0;
}

int GCD(int a, int b)
{
  if(b%a == 0)
    return a;
  else
    return GCD(b%a,a);
}

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

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

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

int main(){
  int x,y;
  while(scanf("%d %d",&x,&y)!=EOF)
    cout<<gcd(x,y)<<" "<<lcm(x,y,gcd(x,y))<<endl;
  return 0;
}

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

int u(int a, int b);
int l(int a, int b);

int main(){
  int a, b;
  int gcd, lcm;
  
  while(scanf("%d", &a)!=EOF){
    scanf("%d", &b);
    gcd = u(a, b);
   lcm = l(a, b);
//printf("%d %d\n",gcd, lcm);
    //std::cout << gcd << " " << lcm << std::endl;
  }
  
  return 0;
}

int u(int a, int b){
  while(1){
    if(a==1) return b;
    else     return a;
    if(a>=b){
      a = a % b;
    }else{
      b = b % a;
    }
  }
  
}

int l(int a, int b){
  int i = 2;
  
  while(1){
    if(i>a/2) i = a;
    else if(i>b/2) i = b;
    
    if(a%i==0){
      if(b%i==0){break;}
      else{i++;}
    }else{
      i++;
    }
  }
  return i;
}

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

long a, b, g;

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

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

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

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

int main(){
    int a,b;
    
    while(cin >> a >> b){
        
        int g,l;
        g = l = 0;
        
        /* ?????§??¬?´???° */
        while(true){
            int tmp = 0;
            
            if(a <= 3 || b <= 3){
                break;
            }
            
            if((a % 2 != 0 && a % 3 != 0) ||
               (b % 2 != 0 && b % 3 != 0)){
                break;
            }
            
            if(a % 3 == 0 && b % 3 == 0){
                a /= 3;
                b /= 3;
                tmp = 3;
            }
            else if(a % 2 == 0 && b % 2 == 0){
                a /= 2;
                b /= 2;
                tmp = 2;
            }
            
            if(g == 0){
                g = tmp;
            }
            else{
                g *= tmp;
            }
        }
        
        /* ????°???¬?????° */
        while(true){
            int tmp = 0;
            
            if(a <= 3 || b <= 3){
                l *= a;
                l *= b;
                break;
            }
            
            if((a % 2 != 0 && a % 3 != 0) ||
               (b % 2 != 0 && b % 3 != 0)){
                l *= a;
                l *= b;
                break;
            }
            
            if(a % 3 == 0 && b % 3 == 0){
                a /= 3;
                b /= 3;
                tmp = 3;
            }
            else if(a % 2 == 0 && b % 2 == 0){
                a /= 2;
                b /= 2;
                tmp = 2;
            }
            
            if(g == 0){
                l = tmp;
            }
            else{
                l *= tmp;
            }
        }
        
    }
    
    return 0;
}

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

int gcd(int a,int 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(int a,int b){
	if(a==0 || b==0) return 0;
	int tmp = a/gcd(a,b);
	return tmp*b;
}

int main(){
	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 main(){
	long long unsigned int a, b, r, gcd, lcm, x, y;
	while(cin >> a >> b){
		r = 1;
		x = a;
		y = b;
		while(r = x % y){
			x = y;
			y = r;
		}

		gcd = y;
		lcm = a * b / gcd;	
	
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

C++: //#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <cstdio>
#include<algorithm>
#include <utility>
#define SIZE 1001;
using namespace std;
int main() {
	long long ans, x, y, memox, memoy;
	while (cin >> x >> y) {
		memox = x; memoy = y;
		if (y > x) {
			swap(x, y);
		}
		while (1) {
			if (y == 0) {
				break;
			}
			x %= y;
			swap(x, y);
		}
		ans = (memox*memoy)/x;
		cout << x << " " << ans << endl;
	}
	return 0;
}