This is mostly an addendum to Denis' answer.
The "standard model" of the Eilenberg-Mac Lane space $K(A,n)$ that Denis mentioned has the following number of $k$-dimensional cells: $$ \sum_{m=0}^k \binom{k}{m} (-1)^{k-m} |A|^{\binom{m}{n}} $$
When $n=1$, this is $$ \sum_{m=0}^k \binom{k}{m} (-1)^{k-m} |A|^m = (|A|-1)^k $$ by the binomial theorem, but I don't know a closed-form formula for general $n$. For a chosen $A$ and $n$, there is usually a model with fewer cells, but these have to be constructed "by hand" and there are not many systematic answers.
If you want more of this type of method, you can look at Eilenberg-Mac Lane's papers "On the groups $H(\Pi,n)$" (volume I, volume II, volume III), which appeared in the Annals of Mathematics back in the early 1950s. These cochain-level methods for computing are very difficult and have been heavily supplemented by less explicit machinery, such as Serre's methods that other commenters have mentioned.