I want to calculate resursive terms of a sequence. The following code do this task with fibonacci sequence (sure, could be other sequence).
\documentclass[varwidth,border=5]{standalone}
\usepackage{tikz}
\usepackage{fp}
\usetikzlibrary{fixedpointarithmetic}
\usetikzlibrary{math}
\begin{document}
\tikzset{fixed point arithmetic}
\tikzmath{
function printfib(\i,\f){print {$f_{\i} = \f$\newline};};
function fibonacci(\n) {
int \a, \b, \res;
\a = 0; \b = 1;
if \n == 0 then { \res = \a; };
if \n == 1 then { \res = \b; };
if \n > 1 then {
for \i in {2,...,\n}{
\res = \a + \b;
\a = \b;
\b = \res;
};
};
return \res;
};
int \f, \i;
for \i in {0,1,...,10}{
printfib(\i,fibonacci(\i));
};
}
\end{document}
However, I would like to print this results into a table, with two columns. The first one are the n values and the second ones the nth term of my sequence. Anyone could help me please to insert instructions to do this? In other words, I provide the value for n and I would like to obtain a table with the n values for my sequence. Thank you very much!