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, d,r,s,h;
	cin >> a >> b;

	//c
	h = a;
	s = b;
	for (;;){
		r = h % s;
		if (r == 0) {
			c = s;
			break;
		}
		h = s;
		s = r;
	}

	//d
	h = a;
	s = b;
	if (a < b){
		for (;;){
			if ((b % a)==0){
				d = b;
				break;
			}
			b = b + s;
		}
	}
	else if(a >= b){
		for (;;){
			if ((a % b) == 0){
				d = a;
				break;
			}
			a = a + h;
		}
	}

	cout << c << " "<< d;
	return 0;
}

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

int main(){
	int a,b;
	int i=1;
	int j=1;
	cin>>a>>b;
		while(1){
		if(a%i!=0){
			i++;
			continue;
		}
		if(b%j!=0){
			j++;
			continue;
		}
		if(a/i<b/j){
			j++;
			continue;
		}
		if(a/i>b/j){
			i++;
			continue;
		}
		if(a/i==b/j){
		cout<<a/i<<" ";
		break;
		}
	}
	
	i=1;
	j=1;
	while(1){
	if(a*i<b*j){
		i++;
		continue;
	}
	if(a*i>b*j){
		j++;
		continue;
	}
	if(a*i==b*j){
		cout<<a*i<<endl;
		break;
	}
	}
return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int a,b;
while(scanf("%d %d",&a,&b)!=EOF){
    long long int z=(long long)a*b;
    if(a<b)swap(a,b);
    while(b){
        int d=b;
        b=a%b;
        a=d;
    }
    printf("%d %lld\n",a,z/a);
}


return 0;
}

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

int main()
{
    unsigned long long a, b, _a, _b;

    while( cin >> a >> b )          //ユークリッドの互除法
    {
        _a = a;                     
        _b = b;

        while( a > 0 && b > 0)      //余りが0になるまで
        {
            if( a > b )
                a = a % b;
            else
                b = b % a;
        }

        cout << a + b << " " << _a * _b / ( a + b ) << endl;
    
    }

    return 0;
}

C++: #include <stdio.h>

int gcd(int a, int b) {
	int c = a%b;
	while (c) {
		a = b;
		b = c;
		c = a%b;
	}
	return b;
}

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

int main(void) {
	int a, b;
	while (scanf("%d%d", &a, &b) == 2) {
		printf("%d %d\n", gcd(a, b), lcm(a, b));
	}
	return 0;
}

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

long int Gcm(long int a,long int b){

    long int temp=0;
    long int r=1;
    //aとbの最大公約数を求める
    //a,b入力を行う（a>b）。a=b*q+rの形で計算していく
    //b%rの値が０になったときのbがa,bの最大公約数(cとする)となる
    //最小公倍数は、c*a'=a,c*b'=bを満たすa',b'とcとの積である
    if(a<b){
        temp = a;
        a = b;
        b = temp;
    }
    while(r!=0){
        r = a%b;
        a = b;
        b = r;//aが最大公約数
    }
    return a;
}

int main(){
    long int x,y;
    long int gcd,lcm;

    cin >> x >> y;

    gcd = Gcm(x,y);

    x = x/gcd;
    y = y/gcd;

    lcm = x * y * gcd;

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

    return 0;
}

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

int GCD(int a, int b) { return (a % b ? GCD(b, a % b) : b); }
int LCM(int a, int b) { return ((a / GCD(a, b)) * b); }

int main()
{
  int a, b;
  while (scanf("%d %d", &a, &b) != EOF) {
    cout << GCD(a, b) << " " << LCM(a, b) << endl;
  }
}

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; 
}

if(a < b) {
  return gcd(b, a);
}

    while(r!=0){
    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 <stdio.h>
#include <iostream>
#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);
    std::cout << a << " " << b << std::endl;
  }
  
  return 0;
}

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

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

C++: #include <iostream>

using std;

int main(){
    long a,b;
    a=0;b=0;
    cin >> a >> b;
    if(a<b) {
        long c;
        c=a;
        a=b;
        b=c;
    }
    long answer;
    long d,e,f;
    for(;;){
         if(e==f){
             answer = a*b/f;
             break;
         }
         d=e-f;
         e=f;
         f=d;
    }
    cout<<f<<" "<<answer<<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",lcm, gcd);
    //std::cout << lcm << " " << gcd << std::endl;
  }
  
  return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	long long a,b,s,m,ta,tb,tmp;
	while(cin>>a>>b){
	ta=a,tb=b;
	s=1,m=1;
	if(a<b)swap(a,b);
	else 
	while(true){
		tmp=a;
		a=b;
		b=tmp%a;
		
		if(b==0){
			m=b;
			break;
		}
		if(a<b){
		//cout<<a<<" "<<b<<endl;
		m=1;
		break;
		}
		if(m==0)m=1;
		s=(ta*tb)/m;
		cout<<m<<" "<<s<<endl;
	}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;
 
const int MAX_N=10000;
unsigned long long int a,b;

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

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

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

C++: #include<stdio.h>

int main(void)
{
	int a,b,c,d,z , *q;
	
	scanf("%d%d",&a,&b);
	c = 1;
	d = 1;
	while(1){
		if( a * c < b * d){
			c++;
		}else if( a * c > b * d){
			d++;
		}else if(a * c == b * d){
				*q = a*c;
			break;
		}
	}
	
	while(a % b != 0){
				z = a % b;
				a = b;
				b = z;
	}
	printf("%d %d",b,*q);
}

C++: #include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define MAXM 20006
#define MAXN 1006
#define INF 2100000000
using namespace std;
int n,m;
int gcd(int x,int y)
{
    if(y==0) return x;
    return gcd(y,x%y);
}
int main()
{
    while(scanf("%d",&n)==1)
    {
        scanf("%d",&m);
        int g=gcd(n,m);
        printf("%d %d\n",g,(n/g)*m);
    }
}

C++: #include<stdio.h>
int main(void)
{
    int i,a,b,c;
	scanf("%d %d",&a,&b);
	i=a*b;
	if(a<b){
	    c=a;
		a=b;
		b=c;
	}
	c=a%b;
	while(c!=0){
	    a=b;
		b=c;
		c=a%b;
	}
	i=i/b;
	printf("%d %d\n",b,i);
	return 0;
}

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

C++: 
#include <iostream>
#include<cstdio>
#include<queue>
#include<cmath>
using namespace std;
int n,m;

int GCDi(int a,int b){
   if(b!=0)return GCDi(b,a%b);
    return a;
}
int LCMi(int a,int b){
    int t;
    t = GCDi(a,b);
    return a/t*b;
}
int main(){        int q[100],r[100],p = 0;

    while(~scanf("%d%d",&n,&m)){
        if(n > m){q[p] = GCDi(n,m);r[p] =LCMi(n,m);}
        else {q[p] = GCDi(m,n) ;r[p] =LCMi(m,n);}
        p++;
    }
    for(int i = 0;i < p;i ++) cout<<q[i]<<" "<<r[i]<<endl;
        return 0;
}