# Algorithm missing \state

I am writing this algorithm and this what I have as a result. The \for and \while ... doesn't appear.

\usepackage{algorithm}
\usepackage{algorithmic}
\begin{algorithm}
\caption{Calculate the exact surface of PV  $A_p{v}$ }
\begin{algorithmic}
\REQUIRE $Nmax_{wt}$\\
\FOR{$i=0:1:Nmax_{wt}$}: \\
\STATE $Npvmax = upperbound$\\
\STATE $Npvmin = 0$\\
\STATE $Pw(t) = P_w(t) \times i$ \\
\WHILE{$Npvmax - Npvmin \geq 1$}\\
\STATE $Npv = (NpvMax + NpvMin) / 2$\\
\STATE $Ppv(t) = Ppv(t) \times i$ \\
\STATE $Pre(t) = Ppv(t) + Pw(t)$\\
\STATE proceed Sizing Storage\\
\IF{$LOH(T) \leq LOH_0$ }\\
\STATE $Npvmin \leftarrow Npv / x$\\
\ELSE\\
\STATE $NpvMax \leftarrow Npv$\\
\ENDIF\\
\ENDWHILE\\
\STATE Return (Npv)
\end{algorithmic}
\end{algorithm}


• Welcome to TeX.SE! Please make your code fragment compilable, i.e. as complete small document, which we can copy and compile as it is. – Zarko Jun 6 at 10:03

There are a couple of issues here:

1. You ignored several compilation errors. Never do that!
2. The syntax for \FOR is \FOR{<condition>} <text>\ENDFOR
3. Do not put \\ at the end of lines. algorithmic will automatically take care of breaking lines.
4. You are using a lot of variables names with several letters in math mode, e.g. Nmax. All those names should be wrapped in \mathit{...}, otherwise the interword spacing/kerning of letters in those words will be bad.

Here's a compilable version of your algorithm:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}

\begin{document}
\begin{algorithm}
\caption{Calculate the exact surface of PV  $A_p{v}$ }
\begin{algorithmic}
\REQUIRE $Nmax_{wt}$
\FOR{$i=0:1:Nmax_{wt}$}
\STATE{$Npvmax = upperbound$}
\STATE $Npvmin = 0$
\STATE $Pw(t) = P_w(t) \times i$
\WHILE{$Npvmax - Npvmin \geq 1$}
\STATE $Npv = (NpvMax + NpvMin) / 2$
\STATE $Ppv(t) = Ppv(t) \times i$
\STATE $Pre(t) = Ppv(t) + Pw(t)$
\STATE proceed Sizing Storage
\IF{$LOH(T) \leq LOH_0$ }
\STATE $Npvmin \leftarrow Npv / x$
\ELSE
\STATE $NpvMax \leftarrow Npv$
\ENDIF
\ENDWHILE
\ENDFOR
\STATE Return (Npv)
\end{algorithmic}
\end{algorithm}
\end{document}