TCS Digital Coding Question

TCS Digital Coding Question

Republic Day Celebration

Statement:

Republic Day celebrations are round the corner. To mark the importance of the day, Parade is held as the most soldiers of the Army is performed as a show of strength crucial attraction of this celebration. The parade from the There are 'A' soldiers from the Army and B soldiers from the Navy to participate in the parade All the soldiers should march in rows at the parade. The task here is to find the maximum number of soldiers in each row such that: The number of soldiers in each row should be the same There should be either soldiers from the Navy or Army in each row No combination of both.

Example 1:

Input:

12 15

Output:

3

Explanation:

From the inputs given above Number of army soldiers:12 Number of navy soldiers 15 A common multiplication factor for both 12 and 15 is 3. So, if there are 3 soldiers in each row in the parade. AAA
AAA
AAA
AAA
BBB
BBB
BBB
BBB
BBB