I'm sure you already know about Pascal's triangle. The screenshot above is from an animation in the wikipedia article.

Among other things, Pascal's triangle provides the coefficients for the binomial expansion

`(p + q)`^{n}

. And of course, today we would generate any particular coefficient using the formula for combinations:`C(n,k) = n! / [(n-k)! k!]`

So, for example, the 4th element in the expansion for (p + q)

^{9}is:

`9! / (5! * 4!) = `

(0-based indexing).

I'm working my way (slowly) through a wonderful book called

*Journey Through Genius*, and I want to explore one of the chapters which involves Newton, his form of the expansion, and the connection to infinite series and finally an approximation for π.

But, let's start by simply generating the numbers as one would fill out the triangle, but using Python to do the arithmetic.

output:

code listing: