Go: package main

import (
  "fmt"
)

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

func main() {
  var a,b,c int
  for _, err := fmt.Scan(&a, &b); err == nil; _, err = fmt.Scan(&a, &b) {
    c = gcd(a,b)
    fmt.Println(c, a*b/c)
  }
}

C++: 













































File Edit Options Buffers Tools C++ Help
const int MAX = (int)1e5 + 5;

template<typename T>
T gcd(T a, T b)
{
        T c;
        while (a != 0) {
                c = a; a = b%a;  b = c;
        }
        return b;
}

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

signed main() {
  ll a, b;
  while(cin >> a >> b) {
    cout << gcd(a,b) << " " << lcm(a,b) << endl;
  }
  return 0;
}

C++: #include <iostream>
//include <algorithm>
using namespace std;
int main(){
	int a, b;
	while( cin >> a >> b ){
		int gcd = 1, lcm;
		//cout << max(a,b) << endl;
		for( int i = 2; i < a; i++ ){
			if( a%i == 0 && b%i == 0 ){
				gcd = i;
			}
		}
		lcm = (a / gcd) * b;
		cout << gcd << ' ' << lcm << endl;
	}
}

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;}return 0;}

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

int gcd(int a, int b){
        if(a == 0 ){
            return b;
        } else if ( b == 0)
        {
            return a;
        } else if (a >= b )
        {
            a = a - b * ( a / b ) ;
            return gcd(a,b);
        }
        else if ( b > a)
            {
            b = b - a * ( b / a);
            return gcd(a,b);
        }
}

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

C++: #include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
LL gcd(LL a,LL b)
{
    return b == 0 ? a : gcd(b,a % b);
}
int main()
{
    LL a,b;
    while(scanf("%lld%lld",&a,&b) == 2)
    {
        if(b > a)
            swap(a,b);
        LL res = gcd(a,b);
        printf("%lld %lld\n",res,a * b / res);
    }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int a[2];
int main(){
	while(cin>>a[0]>>a[1]){
		sort(a,a+2);
		for(int i=a[0];;i--){
			if(a[0]%i==0&&a[1]%i==0){
				cout<<i<<" ";
				goto loop;
			}
		}
		loop:;
		for(int i=a[1];;i++){
			if(i%a[0]==0&&i%a[1]==0){
				cout<<i<<endl;
				goto age;
			}
		}
		age:;
	}
	return 0;
}

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

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

}

int main()
{
    long long a,b,x;

    while(scanf("%lld %lld",&a,&b)!=EOF){
        if(a==0 || b==0){
            printf("0 0\n");
            continue;
        }
        else if(a<b){
            x=a;
            a=b;
            b=x;
        }
        x=GCD(a,b);
        printf("%lld %lld\n",x,(a/x)*b);

    }
}

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

typedef long long lli;

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

lli lcm(lli a, lli b) {
  return a*b/gcd(a,b);
}

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

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

using namespace std;

int main()
{
	int  a, b, a1, b1, c, g;
	long l;

	while (cin >> a >> b)
	{
		a1 = a;
		b1 = b;
		if (a == b)
		{
			g = a;
			break;
		}
		if (a == 0 || b == 0)
		{
			break;
		}
		while (1)
		{
			c = abs(a - b);
			if (c == 0)
			{
				break;
			}

			if (a > b)
			{
				a = c;
				g = c;
			}
			else if (a < b)
			{
				b = c;
				g = c;
			}
		}
		l = (a1 / g)*b1;
		cout << g << " " << l << endl;

		a1 = a; b1 = b;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    return (a%b ? gcd(b,a%b) : b);
}

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

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

C++: #include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
ll a, b;
ll gcd(ll a, ll b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}
int main()
{
	while(cin >> a >> b)
		cout << gcd(a, b) << " " << a/gcd(a, b)*b << endl;
	return 0;
}

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

long gcd(int m, int n) {
    if((0 == m) || (0 == n)) return 0;
    while(m != n) {
        if(m > n) m = m - n;
        else n = n - m;
    }
    return m;
}

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

int main() {
    vector<int> v1;
    vector<int> v2;
    while(cin) {
        int a, b;
        cin >> a >> b;
        v1.push_back(a);
        v2.push_back(b);
    }
    for(int i=0; i<v1.size();i++) {
        cout << gcd(v1[i], v2[i]) << " " << lcm(v1[i], v2[i]) << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
 
int main(){
    unsigned int a,b;
    while(~scanf("%u%u",&a,&b)){
        unsigned int c=a,d=b;
        while(a>0&&b>0){
            if(a>b)a=a%b;
            else b=b%a;
        }
        printf("%u %u\n",a+b,c/(a+b)*d);
    }
}

C++: //
//  main.c
//  c
//
//  Created by ????????? on 2016/12/10.
//  Copyright ?? 2016??´ ?????????. All rights reserved.
//

#include <stdio.h>
int main(){
   int a, b, r, lcm, x, y;
    while (scanf("%d %d",&a,&b) != EOF) {
        x=a;
        y=b;
        for (;;) {
            r=x%y;
            if (r==0)
                break;
            x=y;
            y=r;
        }
        lcm=a*b/y;
        printf("%d %d\n",y,lcm);
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )

template<typename T>
T gcd(T m, T n) {
    return n == 0 ? m : gcd(n, m % n);
}

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

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    vector<pair<long, long>> pairs;
    long ta, tb;
    while (cin >> ta >> tb) {
        pair<long, long> tmp;
        tmp.first = ta;
        tmp.second = tb;
        pairs.push_back(tmp);
    }
    
    for (auto p : pairs) {
        cout << gcd(p.first, p.second) << " " << lcm(p.first, p.second) << endl;
    }
    
    return 0;
}

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

int main(){

  int n[2];
  int yaku,bai;
  while(cin >> n[0] >> n[1]){
    sort(n,n+2);
    for(yaku=n[0];1<yaku;yaku--)
      if(n[0]%yaku==0 && n[1]%yaku==0)
	break;

    for(bai=1;bai<=n[0];bai++)
      if((bai*n[1])%n[0]==0){
	bai *= n[1];
	break;
      }
    cout << yaku << ' ' << bai << endl;
  }
  return 0;
}

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

int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b))
	{int gcd=0;
	int lcf=0;
	for(int i=2;i<=min(a,b);i++)
		if(a%i==0&&b%i==0)gcd=i;
	for(int i=b;i>1;i--)
		if(a*i%b==0)lcf=a*i;
	cout<<gcd<<" "<<lcf<<endl;
	}
}