# How to insert end for in my pseudo algorithm and to make it more space friendly?

This is my pseudo algorithm:

\begin{algorithm}[t]
\caption{Generate Disseminated Sequences}\label{euclid}
\begin{algorithmic}[1]
\Function{output}{$memory,input$}
\State $\text{initialize}~ B \gets \text{all zeros}$
\For{$i = 1$ to ${sizeIn}$\text{+1}}
\State $\text{return}~OUTPUT\gets \text{convert \textit{B} to decimal }$
\For{$j = memorySize$ to $2$}
\State $M[j+1] \gets M[j]$
\EndFor
\State $B[i] \gets inputString[i]$
\EndFor
\EndFunction
\end{algorithmic}
\end{algorithm}


My issue is

1. I am not getting end For when I run it.
2. I want to reduce the space that it takes but when I put \vspace after \end{algorithmic} or \end{algorithm} my last line come out of those algorithm space.

You are probably use

\usepackage[noend]{algpseudocode}


This removes all end-clauses from structures. See algpseudocode without end block text. Remove the noend option to restore the end-clauses.

The algorithmic environment is defines as a list. The space afterwards can be adjusted using an etoolbox patch:

\documentclass{article}

\usepackage{algpseudocode,etoolbox}

\begin{document}

Something above \verb|algorithmic|.

\begin{algorithmic}[1]
\State First state
\State Second state
\State Third state
\State Last state
\end{algorithmic}

Something below \verb|algorithmic|.

\hrulefill

\AfterEndEnvironment{algorithmic}{\vspace{50pt}}

Something above \verb|algorithmic|.

\begin{algorithmic}[1]
\State First state
\State Second state
\State Third state
\State Last state
\end{algorithmic}

Something below \verb|algorithmic|.

\end{document}


It is, however, more typical for people to use the algorithmic environment within an algorithm, which is a floating block. In that regard, see Remove space after figure and before text to change any of the parameters related to spacing around floats.

Specifically, you may be interested in adjusting the lengths \textfloatsep or \intextsep.