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 <bits/stdc++.h>
using namespace std;

// GCD
template<class T> inline T gcd(T a, T b) {
    return (a == b) ? a : gcd(b % a, a);
}

// LCM
template<class T> inline T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

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