summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/lisp-on-tex/tug2013/bench/luatex/tarai.tex
blob: e4a51f711ee5c7566f7d4cef3686c45a1059c661 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
\documentclass{article}
\directlua{
  function tarai(x,y,z)
    if(x<=y) then
      return y
    else
      return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
    end
  end
}
\newcommand\tarai[3]{\directlua{tex.print(tarai(#1, #2, #3))}}
\begin{document}
$\mathrm{Tarai}(14,10,6) = \tarai{14}{10}{6}$
\end{document}