The Friedmann equations are consequences of the Einstein field equation when the geometry of spacetime and the matter that occupies spacetime are both assumed to be homogeneous and isotropic. When matter is absent, the solutions include de Sitter spacetime and anti de Sitter spacetime as special cases, depending on the sign of the cosmological constant. This article derives the Friedmann equations in a spacetime with any number of dimensions. The four-dimensional version of this derivation is a standard exercise in the study of general relativity because of its importance in cosmology.