The formula for calculating the number of moles from the number of atoms or molecules is n = N / Avogadro's Number, where n represents the number of moles, N represents the number of atoms or molecules, and Avogadro's Number represents the number of atoms or molecules in one mole.