Help me in solving BMCV2C04 problem

My issue

can anyone please tell me about gcd ,how did we get and how that code works

My code

// Update the '_' in the code below to solve the problem

#include <bits/stdc++.h>
using namespace std;

int main() 
{
	int t;
    cin >> t;
	
	while(t--)
	{
	    int A,B;
	    cin >> A >> B;
	    // Create an empty array
	    int divisors_AandB[100];
	    int i=1;
	    int j=0;
	    
	    while (i <= min(A,B))
	    {
	        // divides both A and B
            if (A%i == 0 and B%i == 0)
            {
                //#append the integer to the list
                divisors_AandB[j]=i;
                j++;
            }
            i++;
	    }
	    //gcd is the greatest common divisor
        int gcd = *max_element(divisors_AandB,divisors_AandB+j);
        //math property
        int lcm = (A*B)/(gcd);
        cout << gcd << " " << lcm;
        cout << endl;
	}
}
	     

Learning course: C++ for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone