Go: package main

import "fmt"

func GCM(a, b int) int {
	if a < b {
		a, b = b, a
	}
	if b == 0 {
		return a
	}
	return GCM(b, a % b)
}

func LCM(a, b int) int {
	return a*b/GCM(a, b)
}

func main() {

	for {
		var a, b int
		var G, L int
		fmt.Scanf("%d %d", &a, &b)
		if a == 0 {
			break
		}
		G = GCM(a, b)
		L = LCM(a, b)
		fmt.Printf("%d %d", G, L)
	}
}

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

// https://onlinejudge.u-aizu.ac.jp/problems/0005
// 正の整数 a,b を入力し、a と b の最大公約数と最小公倍数を出力するプログラムを作成して下さい。

// aとbの最大公約数を返す
int64_t euclid(int64_t a, int64_t b);

int main(){
	// 0 < a,b ≤ 2,000,000,000
	// a と b の最小公倍数は 2,000,000,000 を超えない。
	int64_t a, b;
	
	// 複数のデータセットが与えられる(入力の最後まで処理)
	while(cin>>a>>b){
		// 最大公約数（greatest common divisor）
		int64_t gcd = euclid(a,b);
		
		// 最小公倍数（least common multiple）
		// 　a×b/(aとbの最大公約数)で求まる。
		//  ただしa×bを先に計算するとオーバーフローする可能性があるので注意
		int64_t lcm = a/gcd * b;
		
		cout << gcd <<" "<< lcm <<endl;;
	}
}


// ユークリッドの互除法で最大公約数を求める
int64_t euclid(const int64_t a, const int64_t b){
	return a%b == 0 ? b : euclid(b, a%b);
}

C++: /*
Á·Ï°Ìâ£ºGCD and LCM_AOJ 0005
	´ËÌâÍØÕ¹ÁËLCM(the least common multiple)µÄÇó·¨¡£ 
*/ 

#include <cstdio>
#include <iostream>
using namespace std;

long long a, b;

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

int main()
{
	while(scanf("%lld%lld", &a, &b)!=EOF)
	{
		long long g=gcd(a, b);
		printf("%lld ", g);
		printf("%lld\n", a/g*b);//×¢ÒâÕâÀïÏÈ×ö³ý·¨£¡ 
		
	}
	
	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;
}

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

  int a, b;

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

  return 0;
}

C++: void printFunc(int a,int b,int c,int d,int e,int f);
long gcd(long a,long b);

int main(){
  long a = 0,b = 0;

  while(fscanf(stdin,"%d %d",&a,&b) != EOF){
    printf("%d %d",gcd(a,b),a*b/gcd(a,b));
  }

  return 0;
}

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

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

int gcd(int a, int b) {
    int r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

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

C++: #include<iostream>

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 x,y;
	while( std::cin>>x>>y )
		std::cout<<gcd(x,y)<<' '<<lcm(x,y)<<std::endl;

	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
  int a, b, m, tmp_a, tmp_b;
  while (cin >> a >> b) {
    tmp_a = a;
    tmp_b = b;
    while (tmp_a != 0 && tmp_b != 0) {
      if (tmp_a > tmp_b) {
        tmp_a = tmp_a % tmp_b;
      } else {
        tmp_b = tmp_b % tmp_a;
      }
    }
    m = max(tmp_a, tmp_b);
    if (m == 0) {
      printf("%d %d", 0, 0);
    } else {
      printf("%d %d", a * b / m, m);
    }
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double gcd( double m, double n );
double lcm( double m, double n );
int main(int argc, const char * argv[])
{
    double a=0.0;
    double b=0.0;
    
    while(scanf("%lf",&a)!=EOF){
        scanf("%lf",&b);

        double g = gcd(a, b);
        double l = lcm( a,b );
        
        
        printf("%d",int(g));
        printf(" ");
        printf("%d\n",int(l));
        
    }
    
}
double gcd( double m, double n )
{
	if ( ( 0.0 == m ) || ( 0.0 == n ) )
		return 0;
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

double lcm( double m, double n )
{
	if ( ( 0.0 == m ) || ( 0.0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n);
}

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

int LCG(int x, int y);

int main(){
 int a,b;
 int l,g;
 while(cin >> a >> b){
    g = LCG(a,b);
    l = a*b/g;
    cout << g << " " << l << endl;
 }
}

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

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

main()
{
	int m,n,r,t,min,max;
	while(cin>>m>>n)
	{
		max=m;
		min=n;
		if(n>m)
		{
			t=min;
			min=max;
			max=t;
		}
		while(r=max%min)
		{
			max=min;
			min=r;
		}
		r=m/min*n;
		cout<<min<<" "<<r<<endl;
	}
}

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

bool p[1000100];

int main(){
    long long a, b;
    while(cin >> a >> b){
        cout << __gcd(a, b) << " " << a*b/__gcd(a, b) << endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<climits>
using namespace std;
static long long a, b;

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

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

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

using namespace std;

int d(int, int);
int dd(int, int);

int main(){
  int a, b;
  cin >> a >> b;
  printf("%d %d\n", d(a, b), dd(a, b));
  return 0;
}

int d(int a, int b)
{
  if(a == 0)
    return b;
  if(b == 0)
    return a;
  if(a > b)
  {
    return d(b, a % b);
  }
  else
    return d(a, b % a);
}

int dd(int a, int b)
{
  return a  / d(a, b) * b;
}

C++: #include <stdio.h>
int gcd(long long a,long long b){
	return b==0?a:gcd(b,a%b);
}
long long a,b;
int main()
{
	while(scanf("%ld%ld",&a,&b) != EOF){
		printf("%ld\n%ld\n",gcd(a,b),a * b / gcd(a,b));
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

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) << " " << lem(a,b) << endl;
	}
}

C++: #include <stdio.h>
long long fibo(int n){
    int a, b, c, d, tmp;
        scanf("%d %d", &a, &b);
     d = a * b;
    if(a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }
     c = a % b;
    while(c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
        printf("%d %d\n", b, d / b);
            return 0;
}

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

int GCD(long long int a, long long int b){
    if(a < b) swap(a,b);
    if(b == 0) return a;
    else return GCD(b,a%b);
}
int LCM(int gcd, long long int a, long long int b) {
    return a * b / gcd;
}

int main(){
    int gcd,lcm;
    long long int a,b;
    while(1){
        cin >> a >> b;
        if(cin.eof()) break;
        gcd = GCD(a,b);
        lcm = LCM(gcd,a,b);
        cout << gcd << " " << lcm << endl;
    }
    return 0;
}