Go: package main
import (
	"os"
	"fmt"
	"strconv"
	"bufio"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main(){
	sc.Split(bufio.ScanLines)
	defer out.Flush()

	for sc.Scan(){
		a, b := nextInts()
		x, y := gcd(a, b), lcm(a, b)
		fmt.Fprintf(out, "%d %d\n", x, y)
	}

}

func nextInts()(a, b int){
	s := strings.Split(sc.Text(), " ")
	ra, _ := strconv.Atoi(s[0])
	rb, _ := strconv.Atoi(s[1])
	a = ra
	b = rb
	return
}

func gcd(x, y int) int{
	if x<y{
		gcd(y, x)
	}
	for 0<y{
		r := x%y
		x, y = y, r
	}
	return x
}

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

C++: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_AB (2000000000)

ll A, B;

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}

void solve() {
  ll ans0 = gcd(A, B);
  ll ans1 = A * (B / ans0);


  printf("%lld %lld\n", ans0, ans1);
}

int main() {
  while(scanf("%lld %lld", &A, &B) != EOF){
    solve();
  }

  return 0;
}

C++: #include <iostream>
int g(int x,int y){return y?g(y,x%y):x;}
int main(){
int a,b;
while(~scanf("%d%d",&a,&b))printf("%d %d\n",g(a,b),a*b/g(a,b));
}

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

int main() {
	int a, b, c, d, e, f, g, l;
	while (cin >> a >> b) {
		c = a; d = b;
		e = a; f = b;
		while (1) {
			if (a >= b) {
				a %= b;
				if (a == 0) { g = b; break; }
			}
			else if (a<b) {
				b %= a;
				if (b == 0) { g = a; break; }
			}
		}
		while (1) {
			if (c>d) d += f;
			else if (c < d) c += e;
			if (c == d) { l = c; break; }
		}
		cout << g << " " << l << endl;
	}
}

C++: # -*- coding: utf-8 -*-
import sys
import fractions

def lcm(a,b):
    return a / fractions.gcd(a,b) * b

for s in sys.stdin:
    a,b = map(int,s.split())
    gcd_ab = fractions.gcd(a,b)
    lcm_ab = lcm(a,b)

    print gcd_ab,lcm_ab

C++: #include<iostream>

using namespace std;

//Euclidean algorithm
int gcd(long m, long n)
{
	long t;
	while (n != 0) {
		t = n, n = m % n, m = t;
	}
	return m;
}

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

int main(){
	long m, n;

	while(cin >> m >> n) {
		if(m > n) swap(n, m);
		cout << gcd(n, m) << " " << lcm(n, m) << endl;
	}

	return 0;
}

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)<<endl;;
	return 0;

}

C++: #include<iostream>

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

int main(){
  int a, b, k;

  while(std::cin >> a >> b){
    k = gcd(a,b);
    std::cout << (int)(a*b)/k << " " << gcd(a,b) << std::endl;
  }
}

C++: #include <iostream>


int LCM(int a, int b) {
  int xa, yb;
  int x = 1, y = 1;
  while (true) {
    xa = x * a;
    yb = y * b;
    if (xa == yb) {
      break;
    } else if (xa < yb) {
      x += 1;
    } else {
      y += 1;
    }
  }
  return xa;
}


int GCD(int a, int b) {
  int gcd = 1;
  int num = 2;
  while (num < a / 2 || num < b / 2) {
    if ((a % num) == 0 && (b % num) == 0) {
      gcd *= num;
      a /= num;
      b /= num;
    } else {
      num += 1;
    }
  }
  return gcd;
}

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

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

int main(){
  int a, b;
  while(cin >> a >> b){

    int max = max(a,b);
    int min = min(a,b);

    int gcd = 0, lcm = 0;

    for(int i = 0; i < min; i++){
        if(max % i == 0) 
          gcd = i;
    }
    
    int j = 1;

    while(1){
      if((max * j) % min == 0){ 
        lcm = max * j;
        break;
      }
      else{ 
        i++;
      }
    }
    
    cout << gcd << " " << lcm << endl;
  }
}

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

C++: #include <iostream>
using namespace std;
long long MaxDivisor(long long a, long long b);
long long MinMultiple(long long a, long long b);
int main()
{
	long long m, n;
	while (cin >> m >> n) {
		cout << MaxDivisor(m, n) << " " 
			<< MinMultiple(m, n) << endl;
	}

	//system("pause");
	return 0;
}
///??相除法求最大公?数
long long MaxDivisor(long long a, long long b) {
	long long temp, r;
	if (a < b) {
		temp = a;
		a = b;
		b = temp;
	}
	r = a % b;
	while (0 != r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
long long MinMultiple(long long a, long long b) {
	return (a * b / MaxDivisor(a, b));
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
main()
{
	while(1)
	{
	
	long a,b,c,d,num;
	
	while(scanf("%d%d",&a,&b)!=EOF)
	{ 
	
	   
	
	num=a*b;
	
	for(;b!=0;)
    {
    	c=a%b;
    	a=b;
    	b=c;
	}
	d=num/a;
	cout<<a<<" "<<d<<endl;
}	
    } 
 }

C++: #include<cstdio>

int main(){
	long long a,b,g,l,t;
	while(scanf("%d %d", &a, &b) + 1){
		if(a > b){
			t = a;
			a = b;
			b = t;
		}

		if(b % a){
			t = a / 2;
			for(int i = 2; i <= t; i++){
				if(!(a % i)){
					g = a / i;
					if(!(b % g)){
						printf("%lld %lld\n", g, a * b / g);
						i += t;
					}
				}
			}
		}else{
			printf("%lld %lld\n", a, b);
		}
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int gcd(int a,int b)
{
	int c;
	if(a<b){
		a+=b;
		b=a-b;
		a-=b;
	}
	while(b!=0){
		c=a%b;
		a=b;
		b=c;
	}
	return a;
}
int lcm( int m, int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n);
}
int main(){
	int a,b,i,j,t;
	while(scanf("%d%d",&a,&b)!=EOF){
		cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
	}
return 0;
}

C++: #include<iostream>

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

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

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

int main()
{
	long int a,b,i,min,max,x,y; //x最大公約数 y最小公倍数

	while(cin>>a>>b){
		x=y=0;
		if(a<b){
			min=a; max=b;
		}else{
			max=a; min=b;
		}

		for(i=min,x=0; x==0; i--){
			if(a%i==0 && b%i==0) x=i;
		}
		for(i=max,y=0; y==0; i+=max){
			if(i%a==0 && i%b==0) y=i;
		}

		cout<<x<<" "<<y<<endl;
	}
}

C++: //先辗转相除找gcd再通过gcd求lcm
#include <bits/stdc++.h>

using namespace std;

long long a,b;

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

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