\documentclass{article}
\begin{document}

\section{Indizes}
\directlua{
  for i=0, 15 do
    tex.print("$x_{" .. i .. "}$, ")
  end
}
\section{Quadratzahlen}
\directlua{
  for i=0, 6 do
    tex.print("$" .. i .. "^2 =" ..  i*i .. "$, ")
  end
}

\end{document}