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{subfig}
\else
\usepackage{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:
Best Answer
You're using
algorithm
andalgorithmic
; remove the loading ofalgorithm2e
and ofalgpseudocode
.