\documentclass{article}

\usepackage{listings}

\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

\begin{document}

\begin{lstlisting}[language=Octave]
a = 1;    # Octave comment
b = 2;
c = a^2 + b^2;
for i = 1:10
disp (i)
endfor
\end{lstlisting}

\end{document}