I am trying to write an algorithm which contains nested for loops as follows:
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\title{Algorithm example}
\author{\LaTeX{}}
\date{\today}
\begin{document}
\maketitle
\section{Gibbs sampling Algorithm}
Algorithms can be included using the commands as shown in algorithm \ref{alg:gibbs}.
\begin{algorithm}
\caption{Collapsed Gibbs sampling algorithm for inference}\label{alg:gibbs}
\begin{algorithmic}[1]
\State Choose initial $z$ and $\xi$.
\For{$T$ iterations}
\For{$D$ Subjects}
\For{$N_d$ time segments}
\State do something
\EndFor
\EndFor
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
... and I get following errors:
Undefined control sequence
Package algorithmicx: Some blocks are not closed!!!
I am using IEEE's online template and also checked this question about nested for loops with algorithm, with no luck.
EDIT 1:
Changed \Endfor to \EndFor. The errors disappeared but, gives me same output.

\documentclass{...}, the required\usepackage's,\begin{document}, and\end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – dexteritas Jun 29 '17 at 15:28end forline to terminate the for loop. – kedarps Jun 29 '17 at 15:50noendat\usepackage[noend]{algpseudocode}. – dexteritas Jun 29 '17 at 15:51[noend]did it. Thanks a lot! – kedarps Jun 29 '17 at 15:57algpseudocodewithout end block text – Werner Jun 29 '17 at 18:12