Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I think your problem is indentation. This document works for me. Remember that indentation is syntax for Python.

%!TEX TS-program = sage
\documentclass[12pt]{article}
%In case I ever wanted to do horizontally
%\usepackage[landscape]{geometry}
\usepackage{amsmath,amssymb}
\usepackage[pdftex]{graphicx}
\usepackage{sagetex}


\begin{document}

\begin{sagesilent}
def nmax(max=100):
    n = 1
    an = 20
    while n <= max:
          yield an
          n += 1
          an = 0.9*an-5

a = nmax(30)
S=[]
for i in a:
     S.append(i.n())
\end{sagesilent}

$\sage{S}$

\end{document}