[Tex/LaTex] How to have a “repeat” statement without an “until” statement using algorithmicx package

algorithmicx

I'd like to write something very similar to the algorithm shown below, but using the algorithmicx package. (This example comes from p. 152 of the book Proximal Algorithms by Boyd and Parikh.) How can I have a "repeat" statement without a corresponding "until" statement using algorithmicx?

(I mention the algorithmicx package specifically because I think it's more customizable than other algorithm packages.)

enter image description here

Best Answer

Here's one option using \algblockdefx to define a block and then \algonotext to suppress typesetting the ending part for the block:

\documentclass{article}
\usepackage{algorithmicx,algpseudocode}

\algblockdefx{MRepeat}{EndRepeat}{\textbf{repeat}}{}
\algnotext{EndRepeat}

\begin{document}

\begin{algorithmic}[1]
\State $sum\gets 0$
\State $i\gets 1$
\MRepeat
\State $sum\gets sum+i$
\State $i\gets i+1$
\EndRepeat
\State $i\gets 100$
\end{algorithmic}

\end{document}

enter image description here