there is also a really cool pascals triangle like pattern that developes in three dimensional for for a tri-nomial, 4 dimensional for quad-nomial........ and n-dimensional for an n-nomial.
you can then apply the formula you derived and find a number at any point in the n-dimensional pyramid...