Go: package main

import "fmt"

func main() {
	var a, b int
	var gcd, lcm int

	for {
		_, err := fmt.Scanf("%d %d", &a, &b)
		if err != nil {
			return
		}

		var big, small int
		// GCD
		if a > b {
			big = a
			small = b
		} else {
			big = b
			small = a
		}

		for {
			if big%small == 0 {
				gcd = small
				break
			} else {
				small, big = big%small, small
			}
		}

		// LCM
		lcm = a * b / gcd

		fmt.Println(gcd, lcm)
	}
}

C++: //AA AE
#include <bits/stdc++.h>
using namespace std;
int data[2];
int answer;

int gcd(int a,int b){
    int c;
    if(a<b){
        a+=b;
        b=a-b;
        a-=b;
    }
    while(b!=0){
        c=a%b;
        a=b;
        b=c;
    }
    return(a);
}

int main(){
    while(cin>>data[0]>>data[1]){
        answer=gcd(data[0],data[1]);
        cout<<answer<<" "<<int(data[0]*data[1]/answer)<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main() {

	long long a, b;
	long long min, max;

	while (cin >> a >> b) {

		if (b > a) {
			long long dum = a;
			a = b;
			b = dum;
		}

		//cout << "a=" << a << "b=" << b << endl;
		
		//?????§??¬?´???°????±???????
		//???????????????????????????
		long long new_a = a, new_b = b;
		long long r;
		while (1) {
			r = new_a%new_b;
			if (r == 0) {
				max = new_b;
				break;
			}
			else {
				new_a = new_b;
				new_b = r;
				continue;
			}
		}

		//????°???¬?????°????±???????
		//2,000,000,000?????§?????????
		long long i=1, j=1;
		while (a*i<2000000000&&b*j<2000000000) {
			//cout << "ai=" << a*i << " bj=" << b*j << endl;
			if (a*i == b*j) {
				min = a*i;
				break;
			}
			else if (a*i < b*j) {
				i++;
			}
			else if (a*i > b*j) {
				j++;
			}
			
		}

		cout << max << " " << min << endl;
	}

	return 0;

}

C++: #include<stdio.h>

#define MAX(x,y) ((x>y)?x:y)
#define MIN(x,y) ((x<y)?x:y)

int prime[30000];	//素因数分解用に素数を求めておく.
int count;
int 素因数A[30000],素因数B[30000];	//素因数を入れる。

int GetPrime(int num);	//num以下の素数をprime[i]に保存
void DevPrime(int *p,int num);	//numを素因数分解。素因数prime[i]の数を*(p+i)に保存。
int GetLCM(int *pa,int *pb);
int GetGCD(int *pa,int *pb);

int pwd(int tei,int sisuu){
	int ans = 1;
	for(int i = 0;i < sisuu;i++)
		ans *= tei;
	return ans;
}

int main(){
	count = GetPrime(50000); 

	int a,b;
	int LCM[200],GCD[200],cor = 0;
	while(~scanf("%d%d",&a,&b)){
		DevPrime(素因数A,a);
		DevPrime(素因数B,b);
		LCM[cor] = GetLCM(素因数A,素因数B);
		GCD[cor] = GetGCD(素因数A,素因数B);
		cor++;
	}
	for(int i = 0;i < cor;i++)
		printf("%d %d\n",GCD[i],LCM[i]);
	return 0;
}

int GetPrime(int num){
	int count = 0,i,j;
	for(i = 2;i <= num;i++){
		for(j = 0;j < count;j++){
			if(i%prime[j] == 0)                                                                                                                                                                                                                                               
				break;
		}
		if(j < count)
			continue;
		prime[count] = i;
		count++;
	}
	return count;
}
void DevPrime(int *p,int num){
	int i;
	for(i = 0;i < count;i++){
		//保存したい配列を初期化
		p[i] = 0;
		//割りきれなくなるまでその素数で割る。
		while(num%prime[i]==0){
			num /= prime[i];
			p[i]++;
		}
	}
}
int GetLCM(int *pa,int *pb){
	int ans = 1;
	for(int i = 0;i < count;i++){
		ans *= pwd(prime[i],MAX(pa[i],pb[i]));
	}
	return ans;
}
int GetGCD(int *pa,int *pb){
	int ans = 1;
	for(int i = 0;i < count;i++){
		ans *= pwd(prime[i],MIN(pa[i],pb[i]));
	}
	return ans;
}

C++: #include <iostream>
using namespace std;
 
int gcd(int x, int y) {
    int amari;
    while(y != 0) {
        amari = x % y;
        x = y;
        y = amari;
    }
    return x;
}
 
int lcm(int x, int y) {
    int g = gcd(x, y);
    return x/g*y;
}

int main() {
    int a, b;
    while(true){
        cin >> a >> b;
        if (std::cin.eof()) {
            break;
        }
        cout << gcd(a, b) << ' ' << lcm(a, b) << endl;
    }
}

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

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

int main(){
    int a,b;
    while(cin>>a>>b){
        int gcd_=gcd(a,b);
        cout<<gcd_<<" "<<a*b/gcd_<<"\n";
    }
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  ll a,b;
  while(scanf("%lld %lld",&a,&b) != -1){
    cout << __gcd(a,b) << " " << (a*b/__gcd(a,b)) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

long long kpk(long long n, long long m){
	long long a,b;
	a=n;
	b=m;
	while(a!=b&&b!=a){
		while(a<b){
			a+=n;
		}
		while(b<a){
			b+=m;
		}
	}
	return b;
}

long long fpb(long long n, long long m){	
	int r;
	if (n<m){
		swap(n,m);
	}
	r=n%m;
	while(r>0){
		n=m;
		m=r;
		r=m%m;
	}
	return m;
	}
	
int main(){
	long long a,b;
	while(cin>>a>>b){
		cout<<fpb(a,b)<<' '<<kpk(a,b)<<endl;
	}
}

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 <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)

ll a,b;
ll tmp;

ll gcd(ll a,ll b){
	if((0==a)||(0==b)) return 0;
	
	while(a!=0&&b!=0){
		if(a>b) a %= b;
		else b %= a;
	}
	return a==0?b:a;
}

ll lcm(ll a,ll b){
	if((a==0)||(b==0)) return 0;
	
	return ((a/tmp) * b);
}

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

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
int main(void) {
    while (1) {
        ll a, b, A, B;
        cin >> a >> b;
        A = a; B = b;
        if (a < b) swap(a, b);
        ll r = b;
        while (r) {
            r = a % b;
            a = b;
            b = r;
        }
        cout << a << " " << (A/a) * B << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	long long int a = 0,b = 0;
	long long int ans1 = 0,ans2 = 0,hozon = 0;
	long long int cnt1 = 2,cnt2 = 2;

	while (scanf("%lld %lld",&a,&b) != EOF)
	{
		cnt1 = 2;
		cnt2 = 2;
		if (a == b)
		{
			ans1 = a;
			ans2 = a;
		}
		else if (a % b == 0)
		{
			ans1 = b;
			ans2 = a;
		}
		else if (b % a == 0)
		{
			ans1 = a;
			ans2 = b;
		}
		else
		{
			ans1 = a;
			ans2 = b;
			if (ans1 < ans2)
			{
				hozon = ans1;
			}
			else
			{
				hozon = ans2;
			}
			while (1)
			{
				if (a % hozon == 0 && b % hozon == 0)
				{
					break;
				}
				hozon -= 2;
			}
			while (1)
			{
				while (ans1 < ans2)
				{
					ans1 = a * cnt1;
					cnt1++;
				}
				while (ans2 < ans1)
				{
					ans2 = b * cnt2;
					cnt2++;
				}
				if (ans1 == ans2)
				{
					break;
				}
			}
		}
		printf("%lld %lld\n",hozon,ans2);
	}

	return 0;
}