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++: #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;
}

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;
        }
    }
    if(bigger % smaller == 0){                                    
        answer = smaller;                                         
    } 
    return answer;
}

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

LL GCD(LL a,LL b){ // a>=b とする
	if(a%b) return GCD(b,a%b);
	return b;
}

int main(){
	LL a,b;
	while(cin>>a>>b){
		LL gcd=GCD(max(a,b),min(a,b));
		cout<<gcd<<" "<<a*b/gcd<<endl;
	}
	return 0;
}

C++: #include <stdio.h>

int GetGCD(int x, int y);

int main(void){
    int n,m,gcd,lcm;
    
    while (scanf("%d %d", &n, &m)!=EOF){
        gcd = GetGCD(n,m);
        lcm = n * m / gcd;
        printf("%d %d\n", gcd, lcm);
    }
    return 0;
}

int GetGCD(int x, int y){
    return y%x ? GetGCD(y%x, x) : x;
}

C++: #include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<ll, int> ll_i;
struct edge { int u, v; ll w; };

ll gcd(ll a, ll b) {
	if (b == 0) return abs(a);
	else return gcd(b, a % b);
}

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

C++: #include <iostream>
#include<cstdio>
using namespace std;
long long a,b;
long long  gcd(long long m,long long n){
    if(m<n){
        long long p=n;
        m=n;
        n=p;
    }
    while(n!=0){
        long long  p=m%n;
        m=n;
        n=p;
    }
    return m;
}
long long  lcd(long long  m,long long  n){
    return m*(n/gcd(m,n));
}
int main()
{
    while(scanf(" %d %d",&a,&b)!=EOF){
        cout<<gcd(a,b)<<lcd(a,b);
    }
}

C++: #include <iostream>

using namespace std;

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

int main()
{

    int a, b, g, l;
    while (cin >> a >> b) {
        g = gcd(a, b);
        l = a / g * b;
        cout << g << ' ' << l << endl;
    }
    return 0;
}