# An error in inserting pseudo code in LaTeX

I want to insert a simple pseudo code as follows, but I confront with an error and I am not able to resolve it.

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

\begin{document}

\begin{algorithm}
\begin{algorithmic}[1]
\State $i \gets 1$
\While {$i > 10$}
\State Statement
\EndWhile
\end{algorithmicx}
\end{algorithm}

\end{document}


Note that I am using WinEdt 10.3 to compile my codes.

=======================================================

UPDATE:

I have modified my initial code based on the comment of a user and try to compile the following .tex file, but I still have a problem.

It is worth mentioning that its MWE is also as like as follows:

\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}
\begin{document}
\begin{algorithm}
\caption{My algorithm}\label{a1}
\begin{algorithmic}[1]
\State $i \gets 1$
\While {$i > 10$}
\State Statement
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}


Just remove algorithmic package and the other corresponding preamble, you would be good to go.

\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}

\begin{document}

\begin{algorithmic}[1]
\State $i \gets 1$
\While {$i > 10$}
\State Statement
\EndWhile
\end{algorithmic}

\end{document}


this would give you:

If you want to add labels and captions to this, just add insert the above-mentioned snippet within algorithmic environment into algorithm environment,

\documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm}

\begin{document}
\begin{algorithm}
\caption{My algorithm}\label{a1}
\begin{algorithmic}[1]
\State $i \gets 1$
\While {$i > 10$}
\State Statement
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}


this would give you:

• Copying and pasting the first code you have provided, I could properly compile the algorithm and get the output of it. But when it comes to the second code (with the caption), I face the following errors: ibb.co/g609pyw. Please help me to resolve this problem too. Many thanks in advance. – Moosavi_69 Jan 25 at 8:09
• @Moosavi_69 Your log reads that for some reason, your caption sits outside the floating environment. May be if you post the problematic MWE, I can look into that for you ;) – Raaja Jan 25 at 8:25
• Thanks for the reply. I do not exactly know what do you mean by MWE. But I have provided the .tex file that I compile and the log of errors that I encounter. [TeX file] (ufile.io/wulab) and [error log] (ufile.io/16471). I look forward to your kind helps. – Moosavi_69 Jan 25 at 8:39
• Please don't provide external unsecure links, could you update the .tex file in your question? For MWE have a look here: tex.meta.stackexchange.com/questions/228/… – Raaja Jan 25 at 8:45
• I eliminated the .aux file, and instead of downloading packages from the internet, I allowed WinEdt to install the required packages. It now works. Many thanks. – Moosavi_69 Jan 25 at 9:49