GCD, LCM and Distributive Property
Submissions: 580   Accuracy:

32.36%

  Difficulty: Basic   Marks: 1

Given three integers x, y, z, the task is to compute the value of GCD(LCM(x,y), LCM(x,z)).
Where, GCD = Greatest Common Divisor, LCM = Least Common Multiple.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the integers x, y and z.

Output:
For each testcase, in a  new line, print the value of GCD(LCM(x,y), LCM(x,z)).

Constraints:
1<= T <= 100
1 <= x, y, z <= 106

Example:
Input:
2
15 20 100
30 40 400
Output:
60
120

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra
Author: sujnesh


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.