0 above the Pascal-triangle?
You can just add
\node at (-1,0) {0};
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[rotate=-90]
\node at (-1,0) {0};
\foreach \x in {0,1,...,3}
{
\foreach \y in {0,...,\x}
{
\pgfmathsetmacro\binom{factorial(\x)/(factorial(\y)*factorial(\x-\y))}
\pgfmathsetmacro\shift{\x/2}
\node[xshift=-\shift cm] at (\x,\y) {\pgfmathprintnumber\binom};
}
}
\end{tikzpicture}
\end{document}
Just a small alternative to @Torbjorn's answer (a trick he taught me here ) to avoid using (annoying IMHO, \pgfmathsetmacro
), include the variables to evaluate directly in the loop.
More details in pfg manual v3.1.5.b p1003, section 89 Repeating Things: The Foreach Statement.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[rotate=-90]
\node at (-1,0) {0};
\foreach \x in {0,1,...,3}
{
\foreach [evaluate ={
\binom = factorial(\x)/(factorial(\y)*factorial(\x-\y));
\shift = \x/2 ;
}] \y in {0,...,\x}
{\node[xshift=-\shift cm] at (\x,\y) {\pgfmathprintnumber\binom};}
}
\end{tikzpicture}
\end{document}