Go: package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
)

func getInputAsInt(in string) (int, int) {
	inArr := strings.Split(in, " ")
	// Atoi(s string) (i int, err error) のerrは捨てる
	val1, _ := strconv.Atoi(inArr[0])
	val2, _ := strconv.Atoi(inArr[1])
	return val1, val2
}

func euclidean(val1, val2 int) (int) {
	surp := 1
	for  {
		surp = val1 % val2
		if surp != 0 {
			val1 = val2
			val2 = surp
		} else {
			break
		}
	}
	return val2
}

func calcLCM(val1, val2, gcd int) (int) {
	return val1/gcd*val2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	
	for scanner.Scan() {
		val1, val2 := getInputAsInt(scanner.Text())
		gcd := euclidean(val1, val2)
		lcm := calcLCM(val1, val2, gcd)
		fmt.Println(gcd, lcm)
	}
}

C++: //
//  main.cpp
//  b
//
//  Created by h3037178 on 2017/07/31.
//  Copyright ?? 2017??´ ?????£?????????. All rights reserved.
//

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
    long long a,b,s,d;
    while(cin>>a>>b){
        for(int o=2000000;o>0;o--){
            if(a>=20000000||b>=20000000){
                break;
            }
            if(a%o==0&&b%o==0){
                s=o;
                 d=a*b/s;
                cout<<s<<" "<<d<<endl;
                break;
            }
        }
    }
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int n, m;
    while (2 == scanf("%d%d", &n, &m)) {
        printf("%d %d\n", __gcd(n, m), n / __gcd(n, m)*m);
    }
    return 0;
}

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

using namespace std;

int main() {
	long int  a, b;
	while (cin >> a >> b) {
		cout << __gcd(a, b) << " " << a / gcd(a, b) * b << endl;

	}

}

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

int saidai(long  a,long  b){
	while(b != a){
		if(a > b){
			a -= b;
		}else {
			b -= a;
		}
	}
	return a;
}


long long	saisyou( long  a,long b , long c){
	return a/c*b;
}

int main(){
	long  a,b;
	cin>>a;
	cin>>b;
	long long ans = saidai(a,b);
	cout<<ans<<" "<<saisyou(a,b,ans);;
	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;
		}
		
		else if (a1 == b1)
		{
			g = a1;
			
		}
		else
		{
			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 <iostream>
#include <string>
#include <sstream>
#include <vector>

//typedef struct
//{
//    int left_val;
//    int right_val;
//};

class GcdAndLcm
{
public:
    GcdAndLcm() : m_gcd(0), m_lcm(0) {}
    void Run();

private:
    void readData();
    void GetData(std::string s, int& v1, int& v2);
    int calcGcd(int m, int n);
    int calcLcm(int m, int n);
    void Show();

private:
    std::vector<std::string> m_data;
    unsigned int m_gcd;
    unsigned int m_lcm;
};

void GcdAndLcm::Run()
{
    int val1 = 0, val2 = 0;

    readData();
    
    for (unsigned int i = 0; i < m_data.size(); ++i) {
        GetData(m_data[i], val1, val2);
        m_gcd = calcGcd(val1, val2);
        m_lcm = calcLcm(val1, val2);
        Show();
    }
}
void GcdAndLcm::readData()
{
    std::string line;

    while (std::getline(std::cin, line)) {
        m_data.push_back(line);
    }
}

void GcdAndLcm::GetData(std::string s, int& v1, int& v2)
{
    size_t pos = s.find(" ");
    char tmp[100] = { 0 };
    std::strncpy(tmp, s.c_str(), pos);
    v1 = std::atoi(tmp);
    std::memset(tmp, 0x00, sizeof(tmp));
    pos++;
    std::strncpy(tmp, s.c_str() + pos, s.size() - pos);
    v2 = std::atoi(tmp);
}
int GcdAndLcm::calcGcd(int m, int n)
{
    if ((0 == m) || (0 == n))
        return 0;

    while (m != n)
    {
        if (m > n) m = m - n;
        else         n = n - m;
    }
    return m;
}//gcd

int GcdAndLcm::calcLcm(int m, int n)
{
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / calcGcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

void GcdAndLcm::Show()
{
    std::cout << m_gcd << " " << m_lcm << std::endl;
}

int main()
{
    GcdAndLcm gcdAndLcm;

    gcdAndLcm.Run();
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;

ll gcd(ll s, ll t){
    if(t == 0)  return s;
    return gcd(t, s%t);
}

ll prime_factor(){
    return (a/gcd(a, b)) * b;
}

void solve(){
    cout << gcd(a, b) << " " << prime_factor() << endl;

}

int main(){
    while (cin >> a >> b, cin.eof() != true){
    if(b>a) swap(a, b);
    solve();
    }
    
    return 0;
}

C++: #include <iostream>
int main(){
int a,b,n,i,j;
std::cin>>a>>b;
for(i=1;i<=a||i<=b;++i){
    if(a%i==0 && b%i==0){
    n=i* a/i* b/i;
    j=i;
    }
     }
     std::cout<<j<<" "<<n<<std::endl;
     return 0;
      }

C++: #include <stdio.h>

int main(void){
	int x, y;
	int tx, ty;
	int gcd, lcm;

	while(scanf("%d %d", &x, &y) != EOF){
		tx = x;
		ty = y;
		int r;

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

		gcd = y;
		lcm = tx /gcd * ty;

		printf("%d %d\n", gcd, lcm);
	}

	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
long long gcd(long long a,long long b)
{
    if(b==0)
		return a;
    else return gcd(b,a%b);
}
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<iostream>
using namespace std;
int main(){
    int  i,a,b,c;
    while(cin>>a>>b){
        if(a==b){
            cout<<a<<" "<<a<<endl;
        }
        else{
        if(a<b){
            i=b-a;
        }
        else{
            i=a-b;
        }
    for( int j=i;j>0;){
        if(a%i==0 && b%i==0){
            c=i;
            break;
        }
        i=i-2;
    }
    cout<<c<<" "<<a*b/c<<endl;
        }
    }
    return 0;
}

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

template<typename T>
T gcd(T a, T b) {
	while (a != 0) {
		if (a < b) { //to be a > b
			std::swap(a, b);
		}
		a = a % b;
	}
	return b;
}
template<typename T>
T lcm(const T& a, const T& b) {
	return a * b / gcd(a, b);
}

int main(int argc, char const* argv[])
{
	unsigned long a{}, b{};
	while (std::cin >> a >> b) {
		std::cout << gcd(a, b) << ' ';
		std::cout << lcm(a, b) << std::endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

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

int lcm(int x,int y){
    return x * y / gcd(x,y);
}

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

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

//最大公約数
int gcd(int a, int b)
{
    int r;
    while((r = a % b) != 0) 
    {
        a = b;
        b = r;
    }
    return b;
}


//最小公倍数
int lcm(int a, int b)
{
    return (a * b / gcd(a,b));
}



int main(){

int a,b;

while(cin >> a >> b){
    if(a == -1 or b == -1)  break;
   while(a <= 0 or b <= 0){
       cin >> a >> b;
   }
   if(a > 0 and b > 0){
        cout << gcd(a,b) << " "<< lcm(a,b)<< "\n";
    }
}

return 0;
}

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