Problem:
GCD and LCM

Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.

Input

Input consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.

Constraints

0 < a, b ≤ 2,000,000,000

LCM(a, b) ≤ 2,000,000,000

The number of data sets ≤ 50

Output

For each data set, print GCD and LCM separated by a single space in a line.

Sample Input

8 6
50000000 30000000

Output for the Sample Input

2 24
10000000 150000000

Solution in Ruby (judge verdict: Accepted)

#encoding:utf-8
def find_the_LCM array #arrayの要素は文字
 array.length.times do |i|
  array[i] = array[i].to_i
 end
 i = 1
 while true
  if array[0]*i%array[1] == 0
   break
  end
  i += 1
 end
 return array[0]*i
end

def find_the_GCD array #arrayの要素は文字
 #ユークリッドの互除法を用いる 「アルゴリズムのキホン」p108参照
 array.length.times do |i|
  array[i] = array[i].to_i
 end
 x,y,r = array[0],array[1],array[0]%array[1]
 until r == 0
  x = y
  y = r
  r = x%y
 end
 return y
end

numbers = []
while gets
 numbers.push $_.split
end

i = 0
while i < numbers.length
 print "#{find_the_GCD numbers[i]} #{find_the_LCM numbers[i]}\n"
 i += 1
end