# How to do arithmetic with variables used in for loop?

How can I use arithmetic inside a node's curly brackets? I have this, and it prints for example "0+1" in a circle. I would like to have circles that show the sum of their coordinates.

\begin{tikzpicture}

\foreach \x in {0,1,2,3}
\foreach \y in {0,1,2,3}
\draw [] (\x,\y) circle [radius=0.4] node {\x + \y};

\end{tikzpicture}

• Chapter VIII of the Tikz manual is devoted to the mathematical engine... You should find there all you need. Basically, look for pgfmathparse, pgfmathresult and company. – Rmano Jun 10 '18 at 21:08

In this simple case where only integers are involved you can do the arithmetic using \numexpr.

\documentclass[tikz]{standalone}
\usepackage{pgffor}

\begin{document}

\begin{tikzpicture}

\foreach \x in {0,1,2,3}
\foreach \y in {0,1,2,3}
\draw [] (\x,\y) circle [radius=0.4] node {\the\numexpr\x + \y\relax};

\end{tikzpicture}
\end{document}


which gives

But there must be some TikZ way.

Note: \numexpr is available since 2004 by default with pdflatex with TeXLive distribution. But there is not much of user level documentation I think.