I wrote algorithms using the algorithm and algorithmic packages, but I always get the last line returning 0. I tried to use this solution, but I could not make it work. Below my algorithm code and packages that I'm using.


\usepackage{booktabs} % For formal tables
\usepackage{nameref}% Only if hyperref isn't loaded
\usepackage[autostyle=false, style=english]{csquotes}

  {% \begin{breakablealgorithm}
     \refstepcounter{algorithm}% New algorithm
     \hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
     \renewcommand{\caption}[2][\relax]{% Make a new \caption
       {\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
       \ifx\relax##1\relax % #1 is \relax
       \else % #1 is not \relax
  }{% \end{breakablealgorithm}
     \kern2pt\hrule\relax% \@fs@post for \@fs@ruled

\usepackage{booktabs, caption, makecell}


     \caption{EtHash mining algorithm}
     \REQUIRE daggerset, params, block
     \ENSURE  nonce
      \STATE $nonce=randint(0,2$**$64)$
      \STATE $result = hashimoto(daggerset,$ \\ $get\_dagsize(params,block), params,$ \\ $decode\_int(block.prevhash), nonce);$
      \IF {$result * params$["diff"] $< 2$**$256$}
      \STATE $break;$
      \STATE $nonce = nonce + 1;$
      \IF {$nonce >= 2$**$64$}
      \STATE $nonce = 0;$

      \STATE $return$ $nonce;$


The output is this:

enter image description here

  • 2
    please complete your example so that it is compilable. if I add in \documentclass{article}, and the required \begin{document}, \end{document}, I don't see the =0. so something else in your code must be causing this.
    – Troy
    Jan 6, 2019 at 15:17
  • I've edited the original post.
    – Mutante
    Jan 6, 2019 at 15:23
  • 2
    Remove the loading of algorithm2e and algpseudocode.
    – egreg
    Jan 6, 2019 at 15:40

1 Answer 1


You're using algorithm and algorithmic; remove the loading of algorithm2e and of algpseudocode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.