Go: package main

import (
	"fmt"
	"os"
	"bufio"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	for sc.Scan() {
		var a, b int
		fmt.Sscanf(sc.Text(), "%d %d", &a, &b)
		gcd := gcd(a, b)
		fmt.Printf("%d %d\n", gcd, (a/gcd)*b )
	}
}

func gcd(a int, b int) (gcd int) {
	var i, j, k int
	if a > b {
		i = a
		j = b
	} else {
		i = b
		j = a
	}

	k = i % j

	for k > 0 {
		num := i
		i = j
		j = num % i
		k = i % j
	}

	return j
}

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

using namespace std;

int main()
{
	unsigned long a, b, r, c, d;
	unsigned long ta, tb;
	int i = 0;


	while(cin>>a>>b) {
		
	if (a > b){
		ta = a;
		tb = b;
	} else {
		ta = b;
		tb = a;
	}
	

	while (1) {
	r = ta % tb;
	if (r == 0) break;
	ta = tb;
	tb = r;
	}
	c = tb;
	
	d = a * (b  / c);

	printf("%d %d\n", c, d);
	}

	

	return (0);
}

C++: #include<iostream>
using namespace std;
int main(){
int a,b,x,y,L,i=0;
for(i=0;i<=50;++i){
  cin>>a>>b;
x=a;y=b;
while(1){
  if(x<y){y=y-x;}
  else if(x>y){x=x-y;}
  else if(x==y){break;}
}
L=(a*b)/x;
if(x==1){cout<<y<<" "<<y<<endl;}
else{cout<<y<<" "<<L<<endl;}
}
  return 0;
}

C++: // B.cpp

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int gcd(int, int);
int lcm(int, int);

int main(void) {
	int a, b;
	cin >> a >> b; 
	cout << gcd(a, b) << " " <<  lcm(a, b) << endl;

	return 0;
}

int gcd(int a, int b) {
	int max, min, res;
	
	res = 1;
	
	if(a > b){
		max = a, min = b;
	}
	if(a < b){
		max = b, min = a;
	}
	while(res) {
		res = max % min;
		max = min;
		min = res;
	}
	return max;
}
int lcm(int a, int b) {
	int max, min, res;
	res = 1;
	if(a > b){
		max = a, min = b;
	}
	if(a < b){
		max = b, min = a;
	}
	while(res) {
		res = max % min;
		max = min;
		min = res;
	}
	return a / max * b;
}

C++: //AA AE
#include <bits/stdc++.h>
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 main(){
    int data[2];
    int answer;
    while(cin>>data[0]>>data[1]){
        answer=gcd(data[0],data[1]);
        cout<<answer<<" "<<int(data[0]*data[1]/answer)<<endl;
    }
}

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

int main()
{
	long long a,b,m,n,d,i,k;
	int c=2;
	while(c--)
	{cin>>a>>b;
		if(a>b)
		{
			d=a;
			a=b;
			b=d;
		}
		for(i=a;i>1;i--)
		{
			if((b%i)==0&&(a%i)==0)
			break;
		}
		n=i;
		k=(a*b)/n;
		m=k;
		cout<<n<<" "<<m;
		cout<<endl;
	}
	return 0;
 }

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

int main(){
	long long int a,b,x,y,z;
	
	while(cin >> a >> b){
		x=max(a,b);
		y=min(a,b);
		while(1){
			if(y==0) break;
			z=x%y;
			x=y;
			y=z;
		}
		
		cout << x << ' ' << a*b/x << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int gcd(int x, int y);
int main(){
  int n,m;
  while(cin >>n>>m){
    int x = gcd(n,m);
    cout <<x<<" "<<(n/x)*m<<endl;
  }
  return 0;
}
int gcd(int x, int y){
  int r = x%y;
  if(r == 0) return y;
  else return gcd(y,r);
}

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

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

int main(void){
   int a, b, tmp;
   if (a < b){
       tmp = b;
b = a;
a = tmp;

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

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

int gcd(int x,int y);

int main(){
   while(true){
      int a,b;
      cin >> a >> b;
      if(cin.eof())
         break;
      int c=gcd(a,b);
      cout << a << ' ' << a/c*b << endl;
   }
   return 0;
}

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

C++: #include <iostream>
using namespace std;
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 a,b;
  while(cin >> a >> b){
    if(a < b)swap(a,b);
    cout << gcd(a,b) << ' ' << lcm(a,b) << endl;
  }
  return 0;
}

C++: //最小公倍数と最大公約数を求める
#include<iostream>
#include<cstdio>
#include<algorithm>
unsigned long a,b;//aとbの最小公倍数と最大公約数を求める
unsigned long G,L;//最大公約数と最小公倍数
int GCD(int x,int y){
  int c;
  c = x%y;
  if(c ==0)
    return y;
  else{
    return (GCD(y,c));
 }
}

int main(){
  while(scanf("%lu %lu",&a,&b) != EOF){
    if(a >b)
     G = GCD(a,b);
    else if(a <b)
      G = GCD(b,a);
    else
      G = a;
    
    L = (a*b)/G;
  printf("%lu %lu\n",G,L);

  }
  return 0;
}

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

int main(){
    double a,b;

    while(cin>>a>>b){
        cout<<__gcd(a,b)<<" "<<a / __gcd(a,b) * b <<endl;
    }
    return 0;
}

C++: #include <cstdio>

int main()
{
    long a, b;
    long m, n, temp;

    while (scanf("%ld %ld", &a, &b) != EOF) {
        if (a < b) {
            temp = a;
            b = a;
            a = temp;
        }
        m = a;
        n = b;

        while (n != 0) {
            temp = n;
            n = m % n;
            m = temp;
        }

        printf("%ld %ld\n", m, a / m * b);
    }

    return 0;
}

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);

    }
}