Each molecule contains one atom of A and one atom of B. The reaction does not use all of the atoms to form compounds.
A + B ⟶ Product
Particles: 6 8 6
If six A atoms form six product molecules, each molecule can contain only one A atom.
The formula of the product is ABₙ.
If n = 1, we need six atoms of B.
If n = 2, we need 12 atoms of B. However, we have only eight atoms of B, so the formula of the product must be AB.
Thus, 6A + 6B ⟶ 6AB, with two B atoms left over.