Answers for "write pseudo code latex"

2

latex how to write algorithm pseudocode

% in the header:
% usepackage{algorithm}
% usepackage{algpseudocode}

% in the  body:
begin{algorithm}
  caption{Euclid’s algorithm}
  label{euclid}
  begin{algorithmic}[1]
    Require $xge5$
    Ensure $xle-5$
    Function{Euclid}{$a,b$}
      Comment{The g.c.d. of a and b}
      State $rgets abmod b$
      While{$r neq 0$}
        Comment{We have the answer if r is 0}
        State $agets b$
        State $bgets r$
        State $rgets abmod b$
      EndWhile
      label{euclidendwhile}
      State Return{$b$}
      Comment{The gcd is b}
    EndFunction
  end{algorithmic}
end{algorithm}
Posted by: Guest on February-28-2021

Browse Popular Code Answers by Language