To calculate the number of atoms in a sample of a compound, first determine how many moles of the compound the sample contains, convert those moles into molecules or formula units using Avogadro’s constant, and then multiply by the number of atoms in each molecule or formula unit. If the sample’s mass is known, its molar mass provides the link between mass and moles.
The general relationship is:
Number of atoms = (mass ÷ molar mass) × Avogadro’s constant × number of atoms per molecule or formula unit
Avogadro’s constant is approximately 6.022 × 10²³ entities per mole. The method works for molecular compounds, such as water and carbon dioxide, as well as ionic compounds, such as sodium chloride, provided the chemical formula is interpreted correctly.
Understand what a chemical formula tells you
A chemical formula identifies the elements in a substance and the relative numbers of their atoms. For example, water has the formula H₂O, meaning that each water molecule contains two hydrogen atoms and one oxygen atom. Each molecule therefore contains three atoms in total.
Carbon dioxide, CO₂, contains one carbon atom and two oxygen atoms per molecule, giving three atoms per molecule. Ammonia, NH₃, contains one nitrogen atom and three hydrogen atoms, giving four atoms per molecule.
To find the total number of atoms, add the subscripts in the chemical formula, treating an element without a written subscript as having a subscript of one. For example, CaCl₂ contains one calcium atom and two chlorine atoms per formula unit, for a total of three atoms.
This counting step is essential because the number of molecules and the number of atoms are not the same. A sample containing a certain number of water molecules has three times as many atoms as molecules.
Ionic compounds require a small distinction. Sodium chloride, NaCl, consists of an extended arrangement of positively charged sodium ions and negatively charged chloride ions rather than separate NaCl molecules. Its formula represents a ratio of one sodium ion to one chloride ion. Chemists therefore use the term formula unit for the smallest whole-number ratio represented by an ionic compound’s formula. For atom counting, each NaCl formula unit contains two atoms in the corresponding ratio.
Convert the sample’s mass into moles
A mole is a unit used to count particles in chemistry. One mole contains exactly 6.02214076 × 10²³ specified entities, a quantity known as Avogadro’s constant. Those entities may be atoms, molecules, ions, or formula units, depending on the substance being counted.
When the mass of a sample is given, calculate the amount in moles by dividing the sample’s mass by the compound’s molar mass.
Moles of compound = Sample mass ÷ Molar mass
Molar mass is the mass of one mole of a substance, usually expressed in grams per mole (g/mol). It is calculated from the chemical formula by adding the atomic masses of all the atoms represented in that formula.
For example, water has the formula H₂O. Using approximate atomic masses of 1.008 g/mol for hydrogen and 16.00 g/mol for oxygen, its molar mass is:
Molar mass of H₂O = 2(1.008) + 16.00 = 18.016 g/mol
A 36.0 g sample of water therefore contains:
Moles of H₂O = 36.0 g ÷ 18.016 g/mol ≈ 2.00 mol
This result means that the sample contains approximately two moles of water molecules. It does not mean that the sample contains only two molecules or two atoms. Each mole represents an enormous number of particles.
Convert moles into molecules or formula units
Once the amount of compound in moles is known, multiply it by Avogadro’s constant to determine the number of molecules or formula units.
Number of molecules or formula units = Moles of compound × 6.022 × 10²³
For the 36.0 g water sample, the number of molecules is approximately:
Number of H₂O molecules = 2.00 mol × 6.022 × 10²³ molecules/mol
Number of H₂O molecules ≈ 1.20 × 10²⁴ molecules
The mole units cancel, leaving a count of molecules. This conversion connects a measurable quantity, such as mass, to the microscopic particles that make up the substance.
For an ionic compound, the same calculation gives the number of formula units rather than molecules. For example, multiplying the moles of sodium chloride by Avogadro’s constant gives the number of NaCl formula units in the sample.
Multiply by the number of atoms per particle
The final step is to account for the atoms in each molecule or formula unit. Multiply the number of molecules or formula units by the total number of atoms represented by the chemical formula.
Total number of atoms = Number of molecules or formula units × Atoms per molecule or formula unit
Returning to the 36.0 g water sample, each H₂O molecule contains two hydrogen atoms and one oxygen atom, for three atoms in total.
Total number of atoms = 1.20 × 10²⁴ molecules × 3 atoms/molecule
Total number of atoms ≈ 3.61 × 10²⁴ atoms
Thus, a 36.0 g sample of water contains approximately 3.61 × 10²⁴ atoms. This total includes both hydrogen and oxygen atoms.
The same calculation can determine the number of atoms of a particular element. Since each water molecule contains two hydrogen atoms, the sample contains approximately 2.41 × 10²⁴ hydrogen atoms. Since each molecule contains one oxygen atom, it contains approximately 1.20 × 10²⁴ oxygen atoms.
The total is the sum of the counts for the individual elements.
Work through an example with carbon dioxide
Consider a 22.0 g sample of carbon dioxide, CO₂. To calculate its total number of atoms, begin with its molar mass.
Carbon has an approximate atomic mass of 12.01 g/mol, and oxygen has an approximate atomic mass of 16.00 g/mol.
Molar mass of CO₂ = 12.01 + 2(16.00) = 44.01 g/mol
Next, calculate the number of moles:
Moles of CO₂ = 22.0 g ÷ 44.01 g/mol ≈ 0.500 mol
Convert the amount in moles into molecules:
Number of CO₂ molecules = 0.500 mol × 6.022 × 10²³ molecules/mol
Number of CO₂ molecules ≈ 3.01 × 10²³ molecules
Each carbon dioxide molecule contains three atoms: one carbon atom and two oxygen atoms. Multiply the number of molecules by three:
Total number of atoms = 3.01 × 10²³ × 3
Total number of atoms ≈ 9.03 × 10²³ atoms
The sample contains approximately 3.01 × 10²³ carbon atoms and 6.02 × 10²³ oxygen atoms. Adding these values gives approximately 9.03 × 10²³ atoms altogether.
This example illustrates why the chemical formula matters at the final step. Counting molecules alone would underestimate the total number of atoms by a factor of three.
Calculate the number of atoms directly from the mass
The calculation can be combined into a single equation when the sample’s mass and chemical formula are known.
Total number of atoms = (m ÷ M) × Nₐ × n
Here, m is the sample’s mass in grams, M is the compound’s molar mass in grams per mole, Nₐ is Avogadro’s constant, and n is the total number of atoms in one molecule or formula unit.
For a compound containing several elements, the number of atoms of a particular element can be calculated separately:
Number of atoms of an element = (m ÷ M) × Nₐ × s
In this equation, s is the subscript for that element in the chemical formula, with a missing subscript interpreted as one.
For carbon dioxide, the carbon subscript is one and the oxygen subscript is two. The calculation for oxygen atoms therefore includes a factor of two, while the calculation for carbon atoms includes a factor of one.
These equations provide a direct route from sample mass to atom count without requiring separate written steps. However, showing the intermediate calculations is often useful because it makes errors easier to identify.
Account for parentheses and more complex formulas
Some compounds have chemical formulas that contain parentheses, brackets, or several different elements. In these cases, count every atom represented by the entire formula, paying attention to subscripts outside parentheses.
For example, calcium hydroxide has the formula Ca(OH)₂. The subscript two applies to everything inside the parentheses, so each formula unit contains one calcium atom, two oxygen atoms, and two hydrogen atoms. The total is five atoms per formula unit.
Aluminum sulfate, Al₂(SO₄)₃, contains two aluminum atoms and three sulfate groups. Each sulfate group contains one sulfur atom and four oxygen atoms. The complete formula therefore represents two aluminum atoms, three sulfur atoms, and twelve oxygen atoms, for a total of seventeen atoms per formula unit.
Once the total atom count per formula unit has been established, the remaining calculation is unchanged: determine the moles from the mass, convert the moles into formula units using Avogadro’s constant, and multiply by the total number of atoms per formula unit.
For a particular element, use its total subscript after accounting for the parentheses. In Al₂(SO₄)₃, for instance, the oxygen count is 4 × 3 = 12, not four.
Calculate atom counts when the sample is given in moles
Sometimes a problem provides the amount of compound directly in moles instead of giving its mass. In that case, the molar-mass step is unnecessary.
Multiply the stated number of moles by Avogadro’s constant to obtain the number of molecules or formula units, then multiply by the number of atoms per particle.
For example, 0.25 mol of ammonia, NH₃, contains:
Number of NH₃ molecules = 0.25 mol × 6.022 × 10²³ molecules/mol
Number of NH₃ molecules ≈ 1.51 × 10²³ molecules
Because each ammonia molecule contains four atoms, the total number of atoms is:
Total number of atoms = 1.51 × 10²³ × 4
Total number of atoms ≈ 6.02 × 10²³ atoms
If the question asks for only hydrogen atoms, multiply the number of ammonia molecules by three rather than four. The answer is approximately 4.52 × 10²³ hydrogen atoms.
This distinction between total atoms and atoms of a specific element is important in chemistry calculations. Always identify exactly what the question asks you to count.
Understand scientific notation and significant figures
Atom counts are often expressed in scientific notation because the numbers involved are extremely large. Scientific notation writes a number as a value between one and ten multiplied by a power of ten. For example, 602,200,000,000,000,000,000,000 can be written approximately as 6.022 × 10²³.
The exponent indicates how many places the decimal point shifts. Multiplying by 10²³ moves it 23 places to the right, while multiplying by 10⁻²³ moves it 23 places to the left.
Significant figures also matter. A measured mass of 22.0 g has three significant figures, so a calculated result based on that measurement should generally be reported to three significant figures when the other quantities are sufficiently precise. This is why the carbon dioxide example gives approximately 9.03 × 10²³ atoms rather than an unnecessarily long string of digits.
Avogadro’s constant is exact when expressed as 6.02214076 × 10²³ entities per mole under the modern definition of the mole. In practical calculations, it is often rounded to 6.022 × 10²³. The atomic masses used to calculate molar mass are generally given to a limited number of decimal places, and measured sample masses introduce their own uncertainty.
Rounding should normally be done at the end of the calculation rather than after every intermediate step. Keeping extra digits during intermediate calculations reduces the chance of introducing avoidable rounding errors.
Avoid common calculation errors
One common mistake is multiplying the sample’s mass directly by Avogadro’s constant. Mass and particle count are connected through the mole, so the sample’s mass must first be divided by the compound’s molar mass.
Another mistake is using the molar mass of an element instead of the molar mass of the entire compound. For water, for example, the molar mass must include both hydrogen atoms and the oxygen atom. For a compound with parentheses, every atom represented by the full formula must be included.
A third error is confusing the number of molecules with the number of atoms. Avogadro’s constant converts moles into the number of specified particles, not automatically into the number of individual atoms. A separate multiplication by the number of atoms in each particle is necessary to obtain the total atom count.
Units provide a useful check. Dividing grams by grams per mole produces moles. Multiplying moles by particles per mole produces a particle count. Multiplying that count by atoms per particle produces the total number of atoms. If the units do not cancel as expected, revisit the equation.
Finally, make sure the chemical formula matches the substance being analyzed. Different compounds can contain the same elements in different ratios, which changes both the molar mass and the number of atoms per molecule or formula unit. Hydrated ionic compounds, for example, include water molecules in their formulas, and those atoms must be counted when the entire compound is being considered.
Apply the method to real samples
The calculation assumes that the sample’s mass and chemical composition are known and that the sample consists of the compound specified by its formula. If a sample contains impurities, a mixture of substances, or a solution with a known volume but an unknown concentration, additional information may be needed.
For an impure sample, the mass of the desired compound must be determined from its purity before calculating the number of atoms belonging to that compound. For a solution, the amount of dissolved compound can often be calculated from its molar concentration and volume, provided both are known in compatible units.
The fundamental method remains the same in each case: establish the amount of the compound, convert that amount into molecules or formula units, and use the chemical formula to determine the number of atoms. This approach connects the measurable properties of a sample to the enormous numbers of particles that make up matter and provides a consistent way to solve atom-counting problems across chemistry.

