0

I got these errors while writing an algorithm. Can anyone help?

Missing number, treated as zero.

\ALG@currentblock@0 l.273 \end{algorithmic}

Missing = inserted for \ifnum.

l.273 \end{algorithmic} I was expecting to see <', =', or `>'. Didn't.

The algorithm structure look like this:

\begin{algorithm}[H]
\SetAlgoLined
 \caption{my Algorithm}
 \begin{algorithmic}[1]
 
\FOR {$iteration=1,2,\ldots$}
\STATE  cdss
\ENDFOR
\ENDFOR $t_i$
\RETURN $M^{(R)}$ and $\eta_{t}$
\end{algorithmic}
\end{algorithm}

this is my code

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

\begin{document}

\begin{algorithm}[H]
\SetAlgoLined
 \caption{,MY Algorithm}
 \begin{algorithmic}[1]
 \renewcommand{\algorithmicrequire}{\textbf{Input:}}
 \renewcommand{\algorithmicensure}{\textbf{Output:}}
 \REQUIRE {aaa}
 \ENSURE  { bbb}
 \\ \textit{111} :
\FOR  {$iteration=1,2,\ldots$}
   \STATE  mmm 
     
     \FOR{$iteration=1,2,\ldots$} 
          \STATE   nnnnn
     \ENDFOR

     \FOR {$iteration=1,2,\ldots$}
          \STATE  hhhh
     \ENDFOR
     \FOR {$iteration=1,2,\ldots$}
          \STATE    bbb
     \ENDFOR

\ENDFOR 
\RETURN $t^{(m)}$ 
\end{algorithmic}
\end{algorithm}

\end{document}
2
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Commented May 9, 2021 at 10:24
  • Looks like you are mixing algorithmic and algorithm2e Commented May 9, 2021 at 10:41

1 Answer 1

1

Yo are mixing two different packages for algorithms and you have two \ENDFOR statements in one loop (which throws an error). Try this:

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

\begin{document}

\begin{algorithm}
    \caption{my Algorithm}
    \begin{algorithmic}[1]
        \For {$iteration=1,2,\ldots$}
          \State  cdss
        \EndFor $t_i$
        \Return $M^{(R)}$ and $\eta_{t}$
    \end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

6
  • i tried updated the code but error is still there.. updated the code in question please have a look Commented May 9, 2021 at 17:01
  • @Alex Sometimes, when an error arises, you have to delete auxiliary files such as the aux file. For algorithms, there may be additional files, corrupted from a prior compilation. Commented May 9, 2021 at 17:28
  • i am working on overleaf is there any aux fule generated by overleaf? i cant see sorry for stupid question as i am new to latex Commented May 9, 2021 at 17:41
  • @Alex – Your updated code hangs at the very beginning. Where are all the keywords (e.g. \REQUIRE or \FOR) defined? Commented May 9, 2021 at 20:26
  • dont know i just copied from different links to make it work on my scenario Commented May 9, 2021 at 23:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.