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 main(){
while(true){
   int a = -1;int b = 0;int i = 1;int g = 0;int seki = 1;
	   cin >> a >> b;
          seki = a*b;
	if(a == -1){
		break;
		}
	if(a < b){
		i=a;
		a=b;
		b=i;
		}
for(i = 1;i <= 50;i++){
   
if(b == 1){
  g = a;
  break;
  }
else {
 a = a%b;
 i=a;
 a=b;
 b=i;
 }
}
cout >> g >> " " >> seki/g >> endl;
}
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

LL gcd(LL m, LL n)
{
	if ((0 == m) || (0 == n)) return 0;

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

LL lcm(LL m, LL n)
{
	if ((0 == m) || (0 == n)) return 0;

	return ((m / gcd(m, n)) * n);
}

//================================================
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	LL A, B;
	while (cin >> A >> B) {
		if (A < B) {
			A = B;
			B = A;
		}
		cout << gcd(A, B) << " " << lcm(A, B) << endl;
	}
	return 0;
}

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

using namespace std;

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

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

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>     //by  @山?叶??     A
#include<cstdlib>
#include<cmath>
#include<string>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
double dinf=99999999.9, mm=1e-8;
const int N=10008,inf=0x3f3f3f3f;
ll gcd(ll x,ll y)
{
    if(x%y==0)
        return y;
    else
        return gcd(y,x%y);
}
int main()
{
    ll a,b;
    while(scanf("%lld%lld",&a,&b)!=EOF)
    {
        printf("%lld ",gcd(a,b));
        ll k,ans=1;
        while(k=gcd(a,b),k!=1)
        {
           ans*=k;
           a/=k;b/=k;
        }
        ans=ans*a*b;
        printf("%lld\n",ans);
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  long long int a,b;
  long long int temp,con;
  long long int hk1,hk2;
  while(scanf("%lld %lld",&a,&b)!=EOF){
    if(a>b){
      if(a%b==0){
	hk1=b;
      }else{
	long long int bit=b/2;
	for(long long int i=bit;i>0;i--){
	  if(a%i==0 && b%i==0){
	    hk1=i;
	    break;
	  }
	}
      }
    }else{
      if(b%a==0){
	hk1=a;
      }else{
	long long int dot=a/2;
	for(long long int i=dot;i>0;i--){
	  if(a%i==0 && b%i==0){
	    hk1=i;
	    break;
	  }
	}
      }
    }
    temp=a*b;
    con=temp/hk1;
    hk2=con;
    printf("%lld %lld\n",hk1,hk2);
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

inline int gcd(int a, int b){
    int d_a = 0;
    while(!(a & 1)){ a >>= 1; ++d_a;}

    int d_b = 0;
    while(!(b & 1)){ b >>= 1; ++d_b;}

    while(a != b){
        if(a < b) swap(a, b);
        a -= b;
        do a >>= 1; while(!(a & 1));
    }

    return a << min(d_a, d_b);
}

int a, b;

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

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

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

int main()
{
    long long a;
    long long b;
    while(scanf("%I64d%I64d",&a,&b)!=EOF)
    {
        printf("%I64d %I64d\n",gcd(a,b),(a/gcd(a,b))*b);
    }
return 0;
}

C++: #include<cstdio>
int main(void){
  int a0,a,b0,b,r;
  while(scanf("%d %d",&a,&b)!=EOF){
    b0=b;
    a0=a;
    r=a%b;
    while(r!=0){
      a=b;
      b=r;
      r=a%b;
    }
    printf("%d %d\n",b,(a0/b)*b0);
  }
  return 0;
}

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

using namespace std;

int main() {
    int n, m;
    while(scanf("%d%d", &n, &m) == 2) {
        printf("%d %d\n", __gcd(n, m), m / __gcd(n, m)*n);
    }
    return 0;
}