Go: package main

import "fmt"

func gcd(x, y int64) int64 {
	for y != 0 {
		r := x % y
		x = y
		y = r
	}
	return x
}

func lcm(x, y int64) int64 {
	return x / gcd(x, y) * y
}

func main() {
	for {
		var a, b int64

		fmt.Scanf("%d %d", &a, &b)

		if a == 0 && b == 0 {
			break
		}

		fmt.Printf("%d %d\n", gcd(a, b), lcm(a, b))
	}
}

C++: #include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);  //递归求最大公约数
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);    //递归求最小公倍数
}
int main()
{
    ll a,b;
    while(cin >> a >> b)
    {
        cout << gcd(a,b)<< " "<<lcm(a,b)<<endl;
    }
    return 0;
}

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

int main() {
	long a,b,G;
	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<<endl;
	cout<<a*b/G;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e;
	std::cin>>a>>b;
	d=a;
	e=b;

	while(b!=0){
		c = a % b;
		a = b;
		b = c;
	}
std::cout<<a<<" "<<((e/a)*(d/a)*a);
}

C++: #include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
using namespace std;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    int a,b;
    while(cin>>a>>b){
        if(a<=b)swap(a,b);
        int g=gcd(a,b);
        cout<<g<<" "<<a/g*b<<endl;
    }
}

C++: 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main(){
    int a,b;
    while(cin>>a>>b){
        int x=a,y=b;
        while(true){
            if(x==y)
                break;
            if(x>y)
                x-=y;
            else if(y>x)
                y-=x;
        }
        cout<<x<<" ";
        int keep=x;
        x=a/keep;
        y=b/keep;
        cout<<x*y*keep<<endl;
    }
    return 0;
}

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

int main(){
	int a, b;
	while(cin >> a >> b){
		int p = a, q = b, r;
		while(q)
			r = p % q, p = q, q = r;
		cout << p << " " << a / p * b / p * p << endl; 
	}
	return 0;
}

C++: #include <iostream>

int  main() {

	//?????§??¬?´???° =????????????????????????????????????
	/*(1) a ??? b ??§???????????????????????? r ?????\????????????
	???(2) r ??? 0 ?????? b ????????§??¬?´???°??§?????????????????????????????????
	???(3) ????????§????????¨????????°a = b?????°b = r ??¨?????? (1) ???????????????????????????*/

	 //????°???¬?????° =???a*b???/???a??¨b????????§??¬?´???°?????§?±?????????????
	int a = 0, b = 0, ad = 0, bd = 0, swap, amari, koba = 0;
	std::cin >> a >> b;
	ad = a; bd = b;
	if (b >= a) { swap = a; a = b; b = swap; }
		
	a:
		amari = a%b;
		if (amari == 0) {
			std::cout << b << " ";
			std::cout << ad*bd / b << std::endl;
		}
		else {
			a = b;
			b = amari;
			goto a;
		}
}

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

int gcd(int x, int y){
	if(y == 0){
		return x;
	}
	return gcd(y, x%y);
}

int main(){
	while(true){
		int a,b;
		cin >> a >> b;
		if(cin.eof()){
			break;
		}
		int GCD = gcd(a, b);
		cout << GCD << ' '<< a / GCD * b << endl;
	}
	return 0;
}

C++: #include<iostream>
int e(int a,int b){if(a<b)a^=b^=a^=b;while(a%=b)a^=b^=a^=b;return b;}int main(){for(int a,b,c,s;s=!(std::cin>>a>>b).eof();s&&printf("%ld %ld\n",c,a/c*b))c=e(a,b);}

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

using namespace std;

int find_GCD(int a, int b){
  int max = 0;
  for(int i=min(a, b)/2;i>0;i--){
    if(a%i==0 && b%i==0){
      max = i;
      break;
    }
  }
  return max;
}

int main(){
  int a, b;
  while(cin >> a >> b){
    //    cout << a << " " << b <<endl;
    //    int GCD = find_GCD(a, b);
    //    cout << GCD << endl;
    //    cout << find_GCD(a, b) << endl;
    int GCD = find_GCD(a, b);
    int LCM = a*b/GCD;
    cout << GCD << " " << LCM << endl;
  }

}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int calc(int a, int b) {
	if (!b)return a;
	return calc(b, a%b);
}
int main() {
	int a, b;
	while (cin >> a >> b) {
		int gcd = calc(max(a, b), min(a, b));
		a /= gcd; b /= gcd;
		cout << gcd << ' ' << gcd*a*b << endl;
	}
	return 0;
}

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

int main(void);
int gcd(int x, int y);
int lcm(int x, int y);

int main(){
	int dataset_count = 0;
	int first_num = 0;
	int second_num = 0;

	std::vector<int> first_num_vector;
	std::vector<int> second_num_vector;

	while ((std::cin >> first_num >> second_num) || (dataset_count < 50)){
		dataset_count++;
		first_num_vector.push_back(first_num);
		second_num_vector.push_back(second_num);
	}
	for (int i = 0; i < first_num_vector.size(); i++){
		std::cout << gcd(first_num_vector[i], second_num_vector[i]) << " " << lcm(first_num_vector[i], second_num_vector[i]) << std::endl;
	}
	return 0;
}


// 最大公約数を求める関数
int gcd(int x, int y)
{
	int r;

	if (x == 0 || y == 0)  // 引数チェック
	{
		return 0;
	}

	// ユーグリッドの互除法
	while ((r = x % y) != 0) // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}

//	最小公倍数を求める関数
int lcm(int x, int y)
{
	if (x == 0 || y == 0)  // 引数チェック
	{
		return 0;
	}

	return (x * y / gcd(x, y));
}

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

#define MAX 256

int main(void){
	
	long max[50], min[50];
	for (long i = 0; i < 50; i++){
		max[i] = 0;
		min[i] = 0;
	}

	long a, b;
	long i = 0;

	while (scanf("%d%d", &a, &b) != EOF){
		while (max[i] == 0){
			for (long j = a; j > 0; j--){
				if (a%j == 0 && b%j == 0)max[i] = j;
			}
		}
		long j = 1;
		while (min[i] == 0){
			if ((a*j) % b == 0)min[i] = a*j;
			j++;
		}
		i++;
	}

	for (long j = 0; j < i; j++){
		printf("%d %d\n", max[j], min[j]);
	}

	return 0;
}

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

using namespace std;

int main()
{
	int  a, b, a1, b1, c, g;
	long l;
	
	while (cin>>a>>b)
	{
		a1 = a;
		b1 = b;
		if (a == 0 || b == 0)
		{
			break;
		}
		while (1)
		{
			c = abs(a - b);
			if (c == 0)
			{
				break;
			}

			if (a > b)
			{
				a = c;
				g = c;
			}
			else if (a < b)
			{
				b = c;
				g = c;
			}
		}
		l = (a1 / g)*b1;
		cout << g << " " << l << endl;
		
		a1 = a; b1 = b;
	}
}

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

int main() {
  for(int i = 0; i < 55; i++){
    int a = 0, b = 0, gcd, lcm;
    cin >> a >> b;

    if(a == 0 && b == 0){
      break;
    }
    else{
      int A = max(a, b), B = min(a, b);
      int r = A % B;
      while(r != 0){
        A = B;
        B = r;
        r = A % B;
      }
       gcd = B;

       lcm = gcd * (a / gcd) * (b / gcd);
    }
    cout << gcd << " " << lcm << endl;
  }
}

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*i >= a; i--){
		if (a % i == 0)
			if( b % i == 0)
				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 <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ll a, b;
    while (cin >> a >> b) {
        cout << __gcd(a, b) << " " << a / __gcd(a, b) * b << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

template<class T>
T gcd(T a,T b){
	while(a % b != 0){
		T buf = b;
		b = a%b;
		a = buf;
	}
	return b;
}

int main(){
	ll a,b;
	while(cin>>a>>b){
		ll g = gcd(a,b);
		ll l = a / g * b;

		cout << g << " " << l << endl;
	}
	return 0;
}