Hey mrmaaza123.

With regards to Lagrange's theorem we know that a sub-group needs to be a factor of the total order of the group.

Now in the case of gcd being 1, it means that these sub-groups are going to be disjoint (except for the identity element) which means that the order will be the product of the two sub-groups which will have |a|*|b|.

But when you do not have a gcd of one, it means that you need to check the actual sub-groups themselves.

The other alternative is that you factorize the groups into disjoint sub-groups and then apply the situation with gcd being equal to 1.