1

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.

\documentclass[conference,a4paper]{IEEEtran}


\usepackage{booktabs} % For formal tables
\usepackage{nameref}% Only if hyperref isn't loaded
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx,url}
\ifCLASSOPTIONcompsoc
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\else
\usepackage[caption=false,font=footnotesize]{subfig}
\fi
\usepackage{multirow}
\usepackage{amsmath} 
\usepackage{multirow}
\usepackage[autostyle=false, style=english]{csquotes}
\usepackage{spreadtab}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage[noadjust]{cite}
\usepackage[nolist]{acronym}
\usepackage{enumerate}
\usepackage{algorithm2e}
\usepackage{pgfplots}
\usepackage{algorithmic}
\usepackage{algorithm,algpseudocode,float}
\usepackage{lipsum}

\makeatletter
\newenvironment{breakablealgorithm}
  {% \begin{breakablealgorithm}
   \begin{center}
     \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
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##2}%
       \else % #1 is not \relax
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##1}%
       \fi
       \kern2pt\hrule\kern2pt
     }
  }{% \end{breakablealgorithm}
     \kern2pt\hrule\relax% \@fs@post for \@fs@ruled
   \end{center}
  }
\makeatother

\usepackage{booktabs, caption, makecell}
\renewcommand\theadfont{\bfseries}
\usepackage{threeparttable}
\usepackage{footnote}

\begin{document}



     \begin{algorithm}[H] 
     \caption{EtHash mining algorithm}
     \begin{algorithmic}[1]
     \renewcommand{\algorithmicrequire}{\textbf{Input:}}
     \renewcommand{\algorithmicensure}{\textbf{Output:}}
     \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;$
      \ENDIF
      \STATE $nonce = nonce + 1;$
      \IF {$nonce >= 2$**$64$}
      \STATE $nonce = 0;$
      \ENDIF

      \STATE $return$ $nonce;$
     \end{algorithmic}
     \end{algorithm}

\end{document}

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 at 15:17
  • I've edited the original post. – Mutante Jan 6 at 15:23
  • 2
    Remove the loading of algorithm2e and algpseudocode. – egreg Jan 6 at 15:40
0

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.