GCD and LCM — CodeChef Solution

chase2learn.com
Jun 20, 2021

--

Two integers A and B are the inputs. Write a program to find GCD and LCM of A and B.

Input

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer A and B.

Output

Display the GCD and LCM of A and B separated by space respectively. The answer for each test case must be displayed in a new line.

Constraints

  • 1 <= T <= 1000
  • 1 <= A, B <= 100000

Example

Input:

3 
120 140
10213 312
10 30

Output:

20 840
1 3186456
10 30

Solution — GCD and LCM — CodeChef Solution

https://www.chase2learn.com/2021/06/gcd-and-lcm-codechef-solution.html

--

--

chase2learn.com
chase2learn.com

Written by chase2learn.com

one place| Learn Gain Continue the Chase! Corner for CS, Software engineering, ML, AI, Software Developers, Programmers, CareerPath, Interviews questions.

No responses yet