I wanted to make a picture of a numeric semigroup S(p,q) - draw all points that belong to it smaller than p*q. I don't know how to break the loop. My code does not work:
\documentclass{amsart}
\usepackage{ifthen}
\usepackage{pgfplots}
\usepackage{pgf}
\pgfmathsetmacro{\pvar}{4}
\pgfmathsetmacro{\qvar}{5}
\pgfmathsetmacro{\helpend}{\pvar*\qvar}
\begin{document}
\resizebox{300 pt}{5 pt}{
\begin{tikzpicture}
\foreach \i in {0,...,\qvar}
\foreach \l in {0,...,\pvar}
{
\pgfmathsetmacro{\leftsside}{\pvar*\i+\qvar*\l}
\ifthenelse{\leftsside<\helpend}
{\filldraw[blue] (\pvar*\i+\qvar*\l + \pvar*\qvar,0) circle (5pt); }
{}
}
\end{tikzpicture}
}
\end{document}
If I replace in the loop \leftsside<\helpend by 1<\helpend, it works nicely, but is not the desired outcome. How do I fix it?
I already tried the \breakforeach suggestion from tex.stackexchange.com/questions/39476/while-loops-in-tikz and could not make it work. I liked the idea of solution (to pre-compute an array) of John Kormylo from tex.stackexchange.com/questions/187482/if-then-else-inside-tikz-graph/187514 but I have to admit that I do not know enough to successfully implement it.

\ifthenelse,\ifnumetc functions? (I am not able to find one, but to be honest I don't know even what to look for). – MRH Jun 05 '20 at 19:54\ifnumstuff you can look up section 7 of TeX by topic (texdoc texbytopic). From this comment one may take that some others aren't too excited about theifthenpackage, at least I am not. In particular, when you have pgf at your disposal, you can always use theifthenelsefunction to define some integers that can be used in\ifnumor\ifcasestructures. Unlike\ifthenelse, they can even be used inside paths. – Jun 05 '20 at 20:01\ifthenelse{\i<\qvar \OR \l<\pvar}{ \filldraw[blue] (\pvar*\i+\qvar*\l,0) circle (5pt);}{}work with\ifnum? (in the double loop) Otherwise I'm stuck with `\ifthen'... – MRH Jun 05 '20 at 20:54\documentclass[tikz,border=3mm]{standalone} \begin{document} \begin{tikzpicture} \pgfmathtruncatemacro{\pvar}{4} \pgfmathtruncatemacro{\qvar}{5} \foreach \i in {0,...,\qvar} \foreach \l in {0,...,\pvar} { \pgfmathtruncatemacro{\itest}{(\i<\qvar|| \l<\pvar)} \ifnum\itest=1 \filldraw[blue] (\pvar*\i+\qvar*\l + \pvar*\qvar,0) circle[radius=5pt]; \fi } \end{tikzpicture} \end{document}. – Jun 05 '20 at 20:59ifthen. I was not really joking. But I can see how this can be overwhelming. At the very least I recommend switching toxifthen(but I personally do not use this one either). – Jun 05 '20 at 21:19