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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

int main(){
    typedef unsigned long long ull;
    ull a,b; cin>>a>>b;
    cout << __gcd(a,b) << " ";
    cout << a*b/__gcd(a,b) << endl;
}

C++: #include<iostream>
using namespace std;
long long int gcd(long long int x,long long int y)
{
	if(x%y==0)
	  return y;
	else
       return  gcd(y,x%y);		
	
}
int main()
{
	long long int ans,a,b,t;
    while(cin>>a>>b)
	{
		
		ans=gcd(a,b);
		
		t=a*b/ans;
		cout<<ans<<' '<<t<<endl;
		
	}
	
	return 0;
}

C++: #include<stdio.h>
int main(){
  long a,b,m,l;
  while(scanf("%d %d",&a,%b)!=EOF){
    m = a%b;
    l = a*b;
    while(m){
      a = b;
      b = m;
      m = a%b;
    }
    printf("%d %d\n",b,l/b);
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	long long a,b,c,d,e;
	std::cin>>a>>b;
	d=a;
	e=b;
	if(b>a){
		long long d;
		d = a;
		a = b;
		b = d;
	}
	while(b!=0){
		c = a % b;
		a = b;
		b = c;
	}
std::cout<<a<<" "<<((e/a)*(d/a)*a);
}

C++: #include <iostream>
using namespace std;
int a1,a2;
int gcd,lcm;

int GCD(int a,int b){
    int i = 2;
    int minimum = min(a,b);
    if (minimum == 1) i = 1;
    for(i == 2;i <= minimum; i++){
        if(a % i == 0 && b % i == 0) break;
    }
    return i;
}

int main(){
    while(cin >> a1 >> a2) {
        gcd = GCD(a1,a2);
        lcm = a1*a2/gcd;
        cout << gcd << " " << lcm << endl;
    }
}

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

C++: #include<iostream>

bool listen_numbers(int &,int &);

class Nums
{
private:
	int a,b;//a>=b
	int gcd;
	int lcm;
	
	void calc_gcd();
	void calc_lcm();
public:
	Nums(int,int);
	void echo_gcd();
	void echo_lcm();
};

Nums::Nums(int x,int y)
{
	if(x>=y)
	{
		this->a=x;
		this->b=y;
	}
	else
	{
		this->a=y;
		this->b=x;
	}
	
	this->gcd=0;
	this->lcm=0;
	
}

void Nums::calc_gcd()
{
	int rest1=this->a;
	int rest2=this->b;
	
	int tmp;
	while(rest1!=0 && rest2!=0)
	{
		tmp=rest1%rest2;
		rest1=rest2;
		rest2=tmp;
	}
	this->gcd=rest1;
}

void Nums::calc_lcm()
{
	if(this->gcd==0)
	{
		this->calc_gcd();
	}
	
	this->lcm=(int)((double)this->a*this->b/this->gcd);
}

void Nums::echo_gcd()
{
	if(this->gcd==0)
	{
		this->calc_gcd();
	}
	std::cout<<this->gcd;
}

void Nums::echo_lcm()
{
	if(this->lcm==0)
	{
		this->calc_lcm();
	}
	std::cout<<this->lcm;
}

int main()
{
	int a,b;
	
	for(;listen_numbers(a,b);)
	{
		Nums num=Nums(a,b);
		
		num.echo_gcd();
		std::cout<<" ";
		
		num.echo_lcm();
		std::cout<<std::endl;
	}
	
	return 0;
}

bool listen_numbers(int &a,int &b)
{
	using namespace std;
	
	cin>>a>>b;
	
	if(cin.eof())
	{
		return false;
	}
	else
	{
		return true;
	}
}

C++: 
#include <string>
#include <iostream>
#include <sstream>

long __gcd(long a, long b)
{
//    std::cout << "in __gcd\n";
//    std::cout << "a: " << a << "\nb: " << b << '\n';
    if (b % a == 0) {
//        std::cout << "returning " << a << '\n';
        return a;
    } else {
        return __gcd(b % a ,a);
    }
}

long gcd(long a, long b)
{
    if (a > b)
        return __gcd(b, a);
    return __gcd(a, b);
}

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

int main(void)
{
    int a, b;
    std::string str;

    while (getline(std::cin, str)) {
        std::istringstream str_s(str);
        str_s >> a >> b;

        std::cout << gcd(a, b) << ' ' << lcm(a, b) << '\n';
    }
    
    return 0;
}

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

int gcd( unsigned int, unsigned int );
int main(void)
{
	unsigned int a, b, g, l;

	while( std::cin >> a >> b ){
		g = gcd( a, b );
		l = a * b / g;
		std::cout << g << std::endl;
		std::cout << l << std::endl;
	}

	return 0;
}

int gcd( unsigned int a, unsigned int b ){
	int n, i;
	unsigned int tmp[4];

	tmp[0] = std::max( a, b );
	tmp[1] = std::mix( a, b );

	for( n = 0;; n++ ){
		for( i = 1;(tmp[( n + 2 ) % 3 ] = tmp[ n % 3 ] - tmp[( n + 1 ) % 3 ] * i ) >= tmp[( n + 1 ) % 3]; i++ ){
			if( tmp[( n + 2 ) % 3 ] == 0 ){
				return tmp[( n + 1 ) % 3 ];
			}
		}
		if( n > 2000000000 ){
			return -1;
		}
	}

	return -1;
}

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

int main(){
  long a, b;
  long ca, cb, tmp;
  long gcd, lcm;

  while(cin >> a){
    cin >> b;
    ca=a; cb=b;

    if(ca<cb){
      tmp=ca; ca=cb; cb=tmp;
    }

    while(cb!=0){
      ca%=cb;
      if(ca==0){
        ca=cb;
        break;
      }
      cb%=ca;
    }
    gcd=ca;
    lcm=a*b/gcd;

    printf("%ld %ld\n", gcd, lcm);
  }

  return 0;
}

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

using namespace std;

typedef pair<int, int> P;

int gcd(int a, int b) {
	if (a == 0) return b;
	if (b == 0) return a;

	return gcd(b, a % b);
}

P lcm(int a, int b) {
	int g = gcd(a, b);

	return P(g, a / g * b);
}

int main() {
	char s[1000];
	while (1) {
		string str;
		if ( !getline(cin, str) ) break;

		for (int i = 0; i < str.size(); ++i)
			s[i] = str[i];
		s[str.size()] = '\0';

		int a, b;
		sscanf(s, "%d%d", &a, &b);

		P p = lcm(a, b);

		cout << p.first << " " << p.second << endl;
	}
}

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

using namespace std;

unsigned long long gcd( unsigned long long a, unsigned long long b)
{
	if( b == 0 ) return a;
	else return gcd( b, a % b );
}
int main(int argc, char const* argv[])
{
	unsigned long long a,b,c;

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

C++: #include<iostream>
int gcd(int x,int y){
	if(y==0)return x;
	else return gcd(y,x%y);
}
int main(){
	for(int i=0;i<2;i++){
		int a,b;
		std::cin>>a>>b;
		std::cout<<gcd(a,b)<<" "<<a/gcd(a,b)*b<<std::endl;
		
	}
	return 0;
}

C++: #include <iostream>

auto gcd (unsigned a , unsigned b) -> unsigned
{
    return b ? gcd (b , a % b) : a;
}

auto lcm (unsigned a , unsigned b) -> unsigned
{
    return a / gcd (a , b) * b;
}

auto main () -> int
{
    unsigned int a , b;
    while (std::cin >> a >> b)
    {
        std::cout << gcd (a , b) << ' ' << lcm (a , b) << std::endl;
    }
}

C++: #include<stdio.h>
int main(){
  unsigned long long a,b,m,ca,cb;
  while(scanf("%d %d",&a,&b)!=EOF){
    m = a%b;
    ca = a;
    cb = b;
    while(m){
      a = b;
      b = m;
      m = a%b;
    }
    ca /= b;
    printf("%d %d\n",b,ca*cb);
  }
}

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

int gcd(int a, int b){

int p,q,r;

if(a<b){p=b;b=a;a=p;

}

while((r=b%a)!=0){
   q=b/a;
   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;
}