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++: #include <iostream>                                             
using namespace std;                                            
typedef long long ll;                                           
                                                                
int GCD(ll a,ll b) {                                            
  if (b==0) {                                                   
    return a;                                                   
  }                                                             
  return GCD(b,a%b);                                            
}                                                               
                                                                
int 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 gcd( int m, int n ){
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

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

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

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

template< typename T >
T gcd(T a,T b) {
	return b ? gcd(b,a%b) : a;
}

template< typename T >
T lcm(T a,T b) {
	return a / gcd(a,b) * b;
}

template< typename T >
T extgcd(T a,T b,T &x,T &y) {
	T g=a;
	x=1,y=0;
	if(b) {
		g = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}
	cout<<a<<' '<<b<<' '<<x<<' '<<y<<' '<<g<<endl;
	return g;
}

template< typename T >
T mod_inv(T a,T m) {
	T x,y;
	extgcd(a,m,x,y);
	return (m+ x%m)%m;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

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

}

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

int main(){

  int a, b;
  int lcm=1, gcd=1;

  while( cin >> a >> b ) {
    for(int i=a; i>1; i--) {
      if(a%i == 0 && b%i == 0) {
        lcm = i;
        a = a/i;
        b = b/i;
      }
    }
    gcd = a*b*lcm;
    cout << lcm << " " << gcd <<"\n";
    lcm = 1;
    gcd = 1;
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<utility>
#include<queue>
#include<stack>
using namespace std;
const int M=10000000000;
int gcd(int x,int y);
int Lcm(int x,int y,int z);
int main()
{
	int n,m;
	while(scanf("%d %d",&m,&n)!=EOF)
	{
		int a=gcd(m,n);
		int b=Lcm(m,n,a);
		printf("%d %d\n",a,b);
	}
	return 0;
}
int gcd(int x,int y)
{
	if(y==0)
	{
		return x;
	}
	else 
	{
		return gcd(y,x%y);
	}
}
int Lcm(int x,int y,int z)
{
	return x*y/z;
}

C++: #include <stdio.h>


int main(){

	unsigned long a=0, b=0,i=0,m=0,n=0,B=0;

	while(scanf("%d%d", &a, &b)!=EOF){
		B = b;

		if (a < b){
			i = a;
			a = b;
			b = i;
		}

		while (1){

			n = a%b;
			if (n == 0){
				printf("%d ", b);
				break;
			}
			m = n;
			n = b%m;
			b = m;
		}
		m = a / b;
		m *= B;
		printf("%d\n",m); 
	}

	return 0;
}

C++: #include<stdio.h>
int main(void){
  int a,b,c,d,x,y;
  printf("a,b>");
  scanf("%d,%d",&a,&b);
  for(x=1;x<=a*b;x++){
    if(a%x==0 && b%x==0){
      c=x;
    }
  }
  for(y=a*b;y>=1;y--){
    if(y%a==0 && y%b==0){
      d=y;
    }
  }
  printf("%d,%d",c,d);
  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int a, b,A, B;
	cin >> a >> b;
	int c = a;
	int d = b;
	if (a <= b)
	{
		while (a != 0)
		{
			int r = b%a;
			b = a;
			a = r;
		}
		A = b;
	}
	if (a > b)
	{
		while (b != 0)
		{
			int r = a%b;
			a = b;
			b = r;
		}
		A = a;
	}
	B = c/A*d;
	cout << A << " " << B << endl;
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf (INT_MAX/2)
#define Min INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;
typedef long long ll;



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


int main()
{
    int n;
    while ( 1 ){
        int a,b;
        cin >> a >> b;
        if( a == 0 && b == 0 ) { break; }
        ll G = gcd(a,b);
        cout << G << " " << a * (b / G) << endl;
        //cout << lcm(a,b) << " " << gcd << endl;
    }
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
unsigned int GCD(unsigned int a,unsigned int b) {
	if(a < b) {
		unsigned int tmp = a;
		a = b;
		b = tmp;
	}
	if(b==0) return a;
	GCD(b,a%b);
}
int main() {
	unsigned int a;
	unsigned int b;
	while(cin >> a >> b) {
		unsigned int gcd = GCD(a,b);
		unsigned int lcm = (a / gcd) * b;
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

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

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

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 <iostream>

using namespace std;

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

C++: #include <iostream>
using namespace std;
int gcd(int,int); //最大公約数
int lcm(int,int); //最小公倍数
int main(){
    int a,b;
    while (cin >>a >>b){
        cout << gcd(a,b) << " " << lcm(a,b) << endl;
    }
}

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

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

C++: #include<iostream>
using namespace std;
int main(){
    long int a,b;
    while(cin>>a>>b){
        if(b>a)swap(a,b);
        int lcm=a*b;
        while(a%b){
            int c=a%b;
            a=b;
            b=c;
        }
        cout<<b<<" "<<lcm/b<<endl;
    }
}