I am trying to write pseudo code in my paper. Here is the snippet and image like what I want. Can some one please help me to format it.
\begin{algorithm}
\caption{Euclid’s algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $stringlen\gets length of string$
\State $i\gets patlen$
top:
\eIf{i > stringlen}{
return false\;
}
{
\State $j\gets patlen$
}
loop:
\eIf{ j == 0}{
return j+1\;
}
{
\eIf{string(i) > pat(j)}{
\State $j\gets $j -1$
\State $i\gets $i -1$
\State goto loop
\State Close.
}
{
\State $j\gets patlen$
}
}
\EndWhile\label{euclidendwhile}
\EndProcedure
\end{algorithmic}
\end{algorithm}
it should look like this:
Currently it looks messed up. Any help is appreciable ..
algorithm2e
!