Pascal's Triangle

Snippets Page

Pascal's Triangle, with numbers shaded by parity.

# Source Code

``````\tikz[scale=.4]{
\foreach{\xa/\xb/\xc}in{0/8/2,-2/6/4,0/6/6,2/6/4,-1/5/10,1/5/10,-4/4/6,0/4/20,4/4/6}{\draw(\xa,\xb)node[rectangle,fill=green!30]{\xc};}
\draw(0,10)node[rectangle,fill=green!50!black]{\color{white}1};
\foreach{\xa/\xb}in{-1/1,1/1}{\draw(\xa,9)node[rectangle,fill=green!50!black]{\color{white}\xb};}
\foreach{\xa/\xb}in{-2/1,2/1}{\draw(\xa,8)node[rectangle,fill=green!50!black]{\color{white}\xb};}
\foreach{\xa/\xb}in{-3/1,-1/3,1/3,3/1}{\draw(\xa,7)node[rectangle,fill=green!50!black]{\color{white}\xb};}
\foreach{\xa/\xb}in{-4/1,4/1}{\draw(\xa,6)node[rectangle,fill=green!50!black]{\color{white}\xb};}
\foreach{\xa/\xb}in{-5/1,-3/5,3/5,5/1}{\draw(\xa,5)node[rectangle,fill=green!50!black]{\color{white}\xb};}
\foreach{\xa/\xb}in{-6/1,-2/15,2/15,6/1}{\draw(\xa,4)node[rectangle,fill=green!50!black]{\color{white}\xb};}
\foreach{\xa/\xb}in{-7/1,-5/7,-3/21,-1/35,1/35,3/21,5/7,7/1}{\draw(\xa,3)node[rectangle,fill=green!50!black]{\color{white}\xb};}
}```
```
page revision: 1, last edited: 17 Dec 2008 14:40