Moles = mass (g) / molar mass (g/mol)
Molar mass of copper = 63.5 g/mol
Molar mass of magnesium = 24.3 g/mol
Moles of copper = 6.23 g / 63.5 g/mol = 0.098 mol
Moles of magnesium = 6.23 g / 24.3 g/mol = 0.256 mol
according to the Avogadro constant,
1 mol = 6.022 x 10²³
Hence,
atoms of copper = 0.098 x 6.022 x 10²³ = 5.902 x 10²²
atoms of magnesium = 0.256 x 6.022 x 10²³ = 15.416 10²²
Hence magnesium ribbon has more atoms.