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 <stdio.h>
int main()
{
  long long i,a,b,max,min,a2,b2;
  while(scanf("%lld %lld",&a,&b)!=EOF){
    if(a<b){
      i=a;
      a=b;
      b=i;
    }
    a2=a;
    b2=b;
    while(1){
      if(b2==0){
	max=a2;
	break;
      } else{
	i=a2%b2;
	a2=b2;
	b2=i;
      }
    }
    min=(a/max)*(b/max)*max;
    printf("%lld %lld\n",max,min);
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int a,b,c,max=0,min=0,bet,les,ch1,ch2;
  vector<int> ayaku;
  vector<int> byaku;
  while(cin>>a>>b){
    for(int i=1;i<=a;i++){
      if(a%i==0)
	ayaku.push_back(i);
    }
    for(int j=1;j<=b;j++){
      if(b%j==0)
	byaku.push_back(j);
    }
    for(int i=0;i<ayaku.size();i++){
      for(int j=0;j<byaku.size();j++){
	if(ayaku[i]==byaku[j]&&max<byaku[j])
	  max=byaku[j];
      }
    }//?????§??¬?´???°??????
    min=(a/max)*b;
    cout<<max<<" "<<min<<endl;
  }
  return 0;
}

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 + 1;
    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<cstdio>
#include<algorithm>
using namespace std;
int main(){
	long long int a,b,ans;
	while(cin>>a>>b){
		for(int i=2;i<=(min(a,b);i++){
			if(a%i==0 && b%i==0)ans=i;
		}
		cout<<ans<<ans*(a/ans)*(b/ans)<<endl;
	}
    return 0;
}

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

int main() {
	long a,b,G;
	while (cin>>a>>b){
	long c = 1;
	for (c = 1;c <= b ;c= c+1){
		if(a%c == 0 , b%c == 0){
			G = c;
		}
	}cout<<G<<" "<<a*b/G<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
long gcd(long n,long m){
	if (m == 0) return n;
	return gcd(m, n % m);
}

long lcm(long n, long m) {
	return m / gcd(n, m)*n;
}

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

C++: #include <iostream>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    long long a,b,gcd,lcm;
    long long c,d;
    while(true) {
        cin >> a >> b;
        if(!cin)
            return 0;
        c = a; d = b;
        while(true){
            if(a>b)
                swap(a,b);
            b = b%a;
            if(b == 0)
                break;

        }
        gcd = a;
        lcm = c/gcd*d; 
        cout << gcd << ' ' << lcm << '\n';
    }
}

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

long long gcd(long long  a,long long b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main()
{
	long long  n, m;
	while(scanf("%ld %ld",&n,&m)!=EOF)
	{
		long long  tmp,tnp;
		if(n>m)
		{
			tmp=n;
			tnp=m;
		}
		else
		{
			tmp=m;
			tnp=n;
		}
		printf("%ld %ld\n",gcd(tmp,tnp),n/gcd(tmp,tnp)*m);
	}
	return 0;
}

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

using namespace std;

int max(int x, int y){
        int r;

        while((r = x % y) != 0){
                x = y;
                y = r;
        }
        return y;
}

int small(int x, int y, int r){
        if(x * y % r  == 0)
                return x * y / r;
        else
                return x * y;
}       

int main(){
        int x,y,r;

        while((scanf("%d %d",&x,&y)) != EOF){
                if(x < y){
                        int num = y;
                        y = x;
                        x = num;
                }
                cout << max(x,y) << " " << small(x,y,max(x,y)) << endl;
        }
}

C++: #include<iostream>

int main(){
	int x,y;
	std::cin>>x>>y;
	
	for(int j=x;j>0;--j){
		if(x%j==0&&y%j==0){
			std::cout<<j<<' ';
			break;
		}
	}

	for(int i=x;i>0;++i){
		if(i%x==0&&i%y==0){
			std::cout<<i<<std::endl;
			break;
		}
	}

	return 0;
}

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

int gcd(int a, int b)
{
    int i;
    if (b > a){
        int j = a;
        a = b;
        b = j;
    }
	for (i = a; i >= 1; i--){
		if (a % i == 0)
			if( b % i == 0)
				break;
	}
	return i;
}


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 <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <iomanip>


using namespace std;


int main(void) {
	int a, b;
	while(cin >> a >> b){
		int gcd = 1, lcm = a * b;
		if(a < b){
			int tmp = a;
			a = b;
			b = tmp;
		}
		for(int i = 2; i <= b; i++){
			while(a % i == 0 && b % i == 0){
				gcd *= i;
				a /= i;
				b /= i;
			}
		}
		lcm /= gcd;
		cout << gcd << " " << lcm << endl;
	}
}

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

C++: #include<cstdio>
#include<iostream>
int main()
{ int a,b,p,i;
 while(scanf("%d%d",&a,&b)!=EOF)
 {int i;
  if(a>b)p=a,a=b,b=p;
  for(i=a;i>=1;i--)
  if(a%i==0&&b%i==0){printf("%d ",i);break;}
  a=a/i;b=b/i;
  printf("%d\n",a*b*i);
 }
 return 0;}

C++: #include <iostream>
#define SWAP(a,b) (a ^= b,b = a ^ b,a ^= b)

typedef unsigned int uint;
typedef long long ll; 
using namespace std;

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

int main() {
  uint  a, b, r;
  while (cin >> a >> b) {
    if (a < b) SWAP(a, b); 
    r = solve(a, b); 
    cout << r << " " << (ll)a * (ll)b / r << endl;
  }
  return 0;
}

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

int main(){
   int a, b, tmp, m=0, s=0, ai, bi;
   while(cin >> a >> b){
      ai=a; bi=b;
      if(a<b){
         tmp=a;
         a=b;
         b=tmp;
      }
      while(1){
         if(a%b==0){
            m=b;
            break;
         }
         else{
            a=a-b;
            tmp=a;
            a=b;
            b=tmp;
         }
      }
      s=ai*bi/m;
      cout<< m << " " << s << endl;
   }
   return 0;
}