I want to draw Sierpinski's triangle in Pascal's triangle in tikz for 30 rows or more but my code only works for 13 rows.
\documentclass{article}
\usepackage{tikz}
\usepackage{pdfpages}
\begin{document}
\begin{center}
\newdimen\R
\R=.4cm
\newcommand\mycolor{white}
\newcommand\thik{\pgflinewidth}
\begin{tikzpicture}[line width=.8pt]
\foreach \k in {0,...,13}{
\begin{scope}[shift={(-60:{sqrt(3)*\R*\k})}]
\pgfmathtruncatemacro\ystart{13-\k}
\foreach \n in {0,...,\ystart}{
\pgfmathtruncatemacro\newn{\n+\k}
%binomila ceeficients
\pgfmathsetmacro{\value}{1};
\ifthenelse{\k>0}{
\foreach \b in {1,...,\k}{
\pgfmathtruncatemacro{\value}{\value*(\newn-\b+1)/\b)};
\global\let\value=\value
}
}{};
\pgfmathtruncatemacro{\rest}{mod(\value,2)};
\ifthenelse{\rest=0}{\def\mycolor{green}}{}
\begin{scope}[shift={(-120:{sqrt(3)\R\n})}]
\draw[top color=\mycolor!20,bottom color=\mycolor!60]
(30:\R) \foreach \x in {90,150,...,330} {
-- (\x:\R)}
--cycle (90:0) node {\tiny $\mathbf{\value}$};
\end{scope}
}
\end{scope}
}
\end{tikzpicture}
\end{center}
\end{document}


![[5]{20}](../../images/3cae82cb494630c9ae3578d3a0043d09.webp)
centerenvironement. But it requirespdfpages, which doesn't seem to be required AFAIK. I have the feeling something is not right here ... and this shows up if you got to 30 but not with 13. – BambOo Dec 15 '20 at 11:03\end{center}, then it compiles. – gernot Dec 15 '20 at 11:11\pgfmathtruncatemacro{\value}{\value*(\newn-\b+1)/\b)};TikZ uses TeX dimensions, and these registers can only hold values±16383.99999. See e.g. the article \pgfmathsetmacro - dimension too large (biggest value allowed?) – gernot Dec 15 '20 at 11:14pgfplotsand thefpulibrary. – gernot Dec 15 '20 at 11:18[tikz]{standalone}class it does not work as well ... as I said, very weird – BambOo Dec 15 '20 at 11:19pdfpages, which does not make sense here. Actually, the compilation failed in astandalonebecause of the\ifthenelseconstructs. It appearspdfpagesloadsifthenexplaining why it works withpdfpageseven if it's overkill to load it. – BambOo Dec 15 '20 at 13:44