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<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;

#define MAX 256

int main(void){
	
	long max[50], min[50];
	for (long i = 0; i < 50; i++){
		max[i] = 0;
		min[i] = 0;
	}

	long a, b;
	long i = 0;

	while (scanf("%d%d", a, b) != EOF){
		while (max[i] == 0){
			for (long j = a; j > 0; j--){
				if (a%j == 0 && b%j == 0)max[i] = j;
			}
		}
		long j = 1;
		while (min[i] == 0){
			if ((a*j) % b == 0)min[i] = a*j;
			j++;
		}
		i++;
	}

	for (long j = 0; j < i; j++){
		printf("%d %d\n", max[j], min[j]);
	}

	return 0;
}

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

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

long lcm(long m, long n) {
    if(m == 0 || n == 0) return(0);
    return((m * n) / gcd(m, n));
}

int main(void) {
    long a, b;
    while(scanf("%ld %ld", &a, &b) != EOF) {
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
    return(0);
}

C++: #include <stdio.h>
int gcd(__int64 a,__int64 b){
	return b==0?a:gcd(b,a%b);
}
__int64 a,b;
int main()
{
	while(scanf("%ld%ld",&a,&b) != EOF){
		printf("%ld\n%ld\n",gcd(a,b),a * b / gcd(a,b));
	}
	return 0;
}

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

int gcd(int a, int b) {

    int x, r;        
    if(b > a){
        x = a;
        a = b;
        b = x;
    }

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

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 <cstdio>
#include <iostream>

using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){

  int a,b;
  
  
  while(cin >> a >> b){
    
    printf("%d %d\n",gcd(a,b),lcm(a,b));
    
  }
  
  return 0;
  
}

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

int main(){
  int a,b,tmp;
  while(cin >> a >> b){
    int tmp_a = a;
    int tmp_b = b;
    for(;;){
      if(b%a==0) break;
      tmp = a;
      a = b % a;
      b = tmp;
    }
    int GCD = a;
    int LCM = (tmp_b / a)*tmp_a;
    cout << GCD << " " << LCM<< endl;
  }
}

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

using namespace std;

int main() {
    int a,b,a2,b2;
    int lcm,gcd;
    while(cin >> a >> b){
        a2=a;
        b2=b;
        while(a != b){
        if(a>b){a = a-b;}
        else{b=b-a;}
        }
        lcm = a;
        gcd=a2 / lcm * b2;
        cout << lcm << " " << gcd << endl;
    }

}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cmath>
 
using namespace std;

int GCD(int max, int min){
    if(max % min == 0) { return min; }
    else return GCD(min, max % min);
}
 
int main(){
    long long int a, b;
    while(cin >> a >> b){
        long long int gcd = GCD(max(a, b), min(a, b));
        long long int lcm = a * b / gcd;
        cout << GCD(max(a, b), min(a, b)) << " " << lcm << endl;
    }
    return 0;
}

C++: def gcd(a,b)
      if b==0
            a
      else
            gcd(b,a%b)
end
def lcm(a,b){a * b / gcd(a,b)}
while line = gets
      a,b = line.split.map(&:to_i)
      print gcd(a,b)," ",lcm(a,b),"\n"
end

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

int lcm(int a, int b);
int gcd(int a, int b);

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

int lcm(int a, int b){
    int sum_a = a;
    int sum_b = b;
    while(true){
        if(sum_a < sum_b){
            sum_a += a;
        } else if(sum_a > sum_b){
            sum_b += b;
        } else {
            return sum_a;
        }
    }
}

int gcd(int a, int b){
    int smaller = a < b ? a : b;
    int bigger = a > b ? a : b;
    int end_point = smaller / 2;
    int counter = 0;
    int answer = 0;
    while(counter <= end_point){
        counter++;
        if(a % counter == 0 && b % counter == 0){
            answer = counter;
        }
    }
    return answer;
}

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

long long a,b;

long long gcd(long long x,long long y){
  if(b == 0) 
    return x;
  else 
    return gcd(y, x % y);
}
long long lcm(long long x,long long y){
    return (x * y) / gcd(x, y);
}

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

C++: #include <iostream>

using namespace std;

int GCD(const int& a, const int& b) {
	int g_a = a;
	int g_b = b;
	if (a == 0 || b == 0)
		return 0;
	while (a != b)
	{
		if (a > b) 
			g_a -= g_b;
		else 
			g_b -= g_a;
	}
	return g_a;
}

int LCM(const int& a, const int& b) {
	int l_a = a;
	int l_b = b;
	if (a == 0 || b == 0)
		return 0;
	return ((l_a / GCD(l_a, l_b)) * l_b);
}

int main() {
	int 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 long int a, b;
	long long int A, B;
	cin >> a >> b;
	long long int c = a;
	long long int d = b;
	if (a <= b)
	{
		while (a != 0)
		{
			long long int r = b%a;
			b = a;
			a = r;
		}
		A = b;
	}
	if (a > b)
	{
		while (b != 0)
		{
			long long int r = a%b;
			a = b;
			b = r;
		}
		A = a;
	}
	B = c*d / A;
	cout << A << " " << B << endl;
	return 0;
}

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

C++: #include <bits/stdc++.h>
using namespace std;

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

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

int main(){
  long long a,b;

  if(a<b) swap(a,b); 
  
  while(cin>>a>>b){
    long long g = gcd(a,b);
    cout<<g<<" "<<lcm(a,b,g)<<endl;
  }

  return EXIT_SUCCESS;
}

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

inline u_int euclid_alg(const u_int a, const u_int b) {
	return a > b ? a % b : b % a;
}

int main(void) {
	u_int a,b;
	std::vector<u_int> num;
	while(std::cin >> a >> b){
		num.push_back(a);
		num.push_back(b);
	}
	
	for(int i = 0; i < num.size(); i+=2){
		u_int pro = num[i] * num[i+1];
		while(num[i] == 0 || num[i+1] == 0){
			if(a > b){
				num[i] = euclid_alg(num[i],num[i+1]);
			}else{
				num[i+1] = euclid_alg(num[i],num[i+1]);
			}
		}
		if(num[i] == 0){
			num[i] = num[i+1];
			num[i+1] = 0;
		}
		num[i+1] = pro / num[i];
	}

	for(int j = 0; j < num.size(); j+=2){
		std::cout << num[j] << " " << num[j+1] << std::endl; 
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int a,b;
int main(){
	while(cin>>a>>b){
		for(int i=a+b;;i--){
			if(a%i==0&&b%i==0){
				cout<<i<<" ";
				goto loop;
			}
		}
		loop:;
		for(int i=1;;i++){
			if(i%a==0&&i%b==0){
				cout<<i<<endl;
				goto age;
			}
		}
		age:;
	}
	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;
}