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<cstdio>
using namespace std;
long long gcd(long long a,long long b)
{
	return b?gcd(b,a%b):a;
}
int main()
{
	long long a,b;
	while(scanf("%I64d%I64d",&a,&b)!=EOF)
	{
		printf("%I64d %I64d\n",gcd(a,b),a/gcd(a,b)*b);
	}
	return 0;
}

C++: #include <stdio.h>

#include <algorithm>

using namespace std;

int getGcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  int rem = a % b;
  while (rem != 0) {
    a = b;
    b = rem;
    rem = a % b;
  }
  return b;
}

int main() {
  //freopen("GcdAndLcm.in", "r", stdin);
  int a, b;
  while (scanf("%d%d", &a, &b) == 2) {
    int gcd = getGcd(a, b);
    int lcm = (long long)a * b / gcd;
    printf("%d %d\n", gcd, lcm);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

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

ll lcm(int a,int b){
	//int table[2][100000];
	//for(int i = 0; i < 2; i++)
	//	fill(table[i],table[i]+100000,0);
	//// 1ÍÇ¿çÌà1Â¾¯Â
	//table[0][1] = 1;
	//table[1][1] = 1;

	//int t_a=a;
	//for(int i = 2; i*i <= t_a; i++){
	//	while(t_a % i == 0){
	//		table[0][i]++;
	//		t_a/=i;
	//	}
	//}
	//if(table[0][t_a] == 0)
	//	table[0][t_a]=1;

	//int t_b=b;
	//for(int i = 2; i*i <= t_b; i++){
	//	while(t_b % i == 0){
	//		table[1][i]++;
	//		t_b/=i;
	//	}
	//}
	//if(table[1][t_b] == 0)
	//	table[1][t_b]=1;

	//ll mul = 1;
	//for(int i = 2; i <= 100000; i++){
	//	if(table[0][i] == 0 && table[1][i] == 0)
	//		continue;
	//	else{
	//		int mc = max(table[0][i],table[1][i]);
	//		for(int j = 0; j < mc; j++)
	//			mul *= i;
	//	}
	//}

	ll mul = 1;
	mul = (b/gcd(a,b))*a;

	return mul;
}

int main(){

	ll a,b;
	while(1){
		cin >> a >> b;
		if(cin.eof()){
			break;
		}
		cout << gcd(a,b) << " " << lcm(a,b) << endl;
	}

	return 0;
}

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

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

long gcd(long a, long b) {

    if ( a < b ) {
        long t = b;
        b = a;
        a = t;
    }

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

}

int main() {

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

        long g = gcd(a, b);
        cout << g << " " << (a / g * b) << endl;
    }
     
    return 0;
}

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

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


int main(){
      ll a,b,c,d;
      while(cin >>a >>b){
            c = gcd(a,b);
            d = a*(b/c);
            cout << c <<' '<< d << endl;
      }
}

C++: #include <stdio.h>

int main(void)
{
	int a, b;
	int l, s;
	int gcd, lcm;
	
	while (scanf("%d %d", &a, &b) != EOF){
		l = a;
		s = b;
		
		if (l < s){
			l = b;
			s = a;
		}
		
		while (s){
			l %= s;
			l += s;
			s = l - s;
			l -= s;
		}
		
		gcd = l;
		lcm = a / gcd * b;
		
		printf("%d %d\n", gcd, lcm);
	}
	
	return (0);
}

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

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

int main()
{
    int min,max,a,b;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
    max = gcd(a,b);
    min = (a/max)*(b/max)*max;
    cout << max << " " << min<<endl;
    }
    return 0;
}

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

long long a, b, g;

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

int main()
{
	while(scanf("%lld %lld", &a, &b) != EOF){
		g = gcd(a, b);
		printf("%lld %lld\n", g, a*b/g);
	} 
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

int main()
{
	int a, b;
	while (cin >> a >> b)
	{
		if (a < b) swap(a, b);
		int A = a; int B = b;
		while (1)
		{
			a -= (a / b)*b;
			if (a == 0) break;
			swap(a, b);
		}
		cout << b << " " << A / b*B << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
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 <algorithm>
using namespace std;
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>
 
using namespace std;
 
int GCD(int a, int b)
{
    if(a % b == 0) { return b; }
 
    if(b % a == 0) { return a; }
 
    if(a > b) { return GCD(a % b, b); }
 
    if(a < b) { return GCD(a, b % a); }
}
 
 
int main()
{
    int a, b;
 
    while(cin >> a >> b)
    {
int n=GCD(a,b);
        cout << n << ' ' << a/n*b << endl;
    }
 
    return 0;
}

C++: #include<iostream>

//最大公約数を求めるプログラム(m >= n)
int calcGcd(int m, int n);
//最小公倍数を求めるプログラム
inline int calcLcm(int m, int n, int gcd);

int main(){
	int gcd, lcm, x, y;
	
	while(std::cin >> x >> y){
		if(x > y) gcd = calcGcd(x, y);
		else gcd = calcGcd(y, x);
		lcm = calcLcm(x, y, gcd);
		
		std::cout << gcd << " " << lcm << std::endl;
	}
}

int calcGcd(int m, int n){
	if(n == 0) return m;
	else return calcGcd(n, m%n);
}

inline int calcLcm(int m, int n, int gcd){
	return m / gcd * n;
}

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

int GCD(int m, int n){
  while(m!=n){
    if(m>n) m-=n;
    else n-=m;
  }
  return m;
}

int LCM(int m, int n){
  return m/GCD(m, n)*n;
}

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

C++: #include <stdio.h>

int main(){
long int a,b,aa,bb;
long int x,y;

while(scanf("%d %d",&a,&b) != EOF){
aa=a;
bb=b;
while(a%b!=0){
x=a%b;
a=b;
b=x;
}
for(i=1;i<=aa*bb;i++){
if(i%aa==0 && i%bb==0){
y=i;
break;
}
}
printf("%d %d\n",b,y);
}
return 0;
}

C++: #include<stdio.h>
int gcd(int x, int y);
int lcm(int x, int y, int g);
int main(){
    int g,l,x,y;
    while (scanf("%d%d",&x,&y) != EOF){
        g=gcd(x,y);
        l=lcm(x,y,g);
        printf("%d %d\n",g,l);
    }
    return 0;
}
int gcd(int x, int y){
    int a,b,c,GCD;
    if(x > y){
        a=x;
        b=y;
        for(;;){
            c = a % b;
            if(a % b == 0){
                GCD=b;
                break;
            }
            a=b;
            b=c;
        }
    }
    else if(x < y){
        a=y;
        b=x;
        for(;;){
            c = a % b;
            if(a % b == 0){
                GCD=b;
                break;
            }
            a=b;
            b=c;
        }
    }
    else if(x == y) GCD=x;
        return GCD;
}
int lcm(int x, int y, int g){
    return (x/g)*(y/g)*g;
}