I am a bit inexperienced with LaTeX and I have a code called "My code" that I want to make look like "Example". I have been trying to do it, but I don't know how to make it exactly similar. Here is the code:
Code: Select all
\begin{lstlisting}[language=Pascal, basicstyle=\ttfamily\small,frame=single,title=SCRIPT,framesep=9pt,stringstyle=\color{violet},showstringspaces=false,keywordstyle=\color{blue},backgroundcolor=\color{white!90},rulecolor=\color{gray!30},identifierstyle=\color{black!85}]
format long
disp('Dada la sucesion a = 1/(1 + 1/sqrt(n))^n')
n=input('Coloque un numero mayor que 0. n = ');
if n <= 0
disp('(ERROR)El numero debe ser entero mayor que 0.')
else
disp(['Estos son los ',num2str(n),' terminos de la sucesion'])
end
a=zeros(1,n);
for m=1:n
a(m)= 1 ./ (1 + 1 ./ sqrt(m)) .^ m;
disp(a(m));
end
if n>0
disp(['La suma de los ',num2str(n),' terminos es ',num2str(sum(a))])
end
\end{lstlisting}