Least Common Multiple and Greatest Common Divisor
InterviewTime limit1sMemory limit128 MB
For multiple integer pairs, compute and print each pair's least common multiple and greatest common divisor.
- Level
Easy1 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
For two integers a and b, their least common multiple is the smallest positive integer that is a multiple of both numbers, and their greatest common divisor is the largest positive integer that divides both numbers.
For several test cases, write a program that finds the least common multiple and greatest common divisor of each given pair.
Input
The first line contains the number of test cases T. T is between 1 and 1,000, inclusive.
Each of the next T lines contains two integers a and b separated by a space. Each integer is between 1 and 1,000, inclusive.
Output
For each test case, print the least common multiple followed by the greatest common divisor on one line.