Go: package main

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

func gcd(num1, num2 int) int {
	if num2 == 0 {
		return num1
	}
	num3 := num1 % num2
	return gcd(num2, num3)
}

func lcm(num1, num2 int) int {
	if num1%num2 != 0 {
		num3 := gcd(num1, num2)
		for i := 1; ; i++ {
			check := num3 * i
			if check%num1 == 0 && check%num2 == 0 {
				return check
			}
		}
	} else {
		return num1
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		row := strings.Fields(scanner.Text())
		nums := []int{}

		for _, v := range row {
			num, _ := strconv.Atoi(v)
			nums = append(nums, num)
		}
		fmt.Println(gcd(nums[0], nums[1]), lcm(nums[0], nums[1]))
	}
}

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;
}

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

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

int lcm(int a,int b){
	int max_common = gcd(a,b);
	return (a/max_common)*b;
}

int main(){
    long long a, b;

	while(scanf("%lld %lld",&a,&b)!=EOF){
		printf("%lld %lld\n",gcd(a,b),lcm(a,b));
	}

    return 0;
}

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

typedef long long LL;

LL GCD(LL a, LL b){
	if (a<b) std::swap(a, b);
	LL lcm = a * b; 
	while (b != 0)  { 
		LL gcd = a % b; 
		a = b; 
		b = gcd; 
	} 
	return a;
}

int main(){
	LL a, b;
	while (~scanf("%lld%lld", &a, &b)){
		LL tmp = GCD(a, b);
		printf("%lld %lld\n", tmp, a*b/tmp);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

int lcm(int a, int b)
{
  return a / gcd(a, b) * b;
}

int main()
{
  int a, b;

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

  return 0;
}