How to round off the result of \pscalculate?

\psCalculate (with an uppercase C) can accept some settings.

\documentclass[12pt,border=5pt]{standalone}
\usepackage{pst-calculate,pgffor}
\def\q{\pscalculate{1/sqrt(5)}}
\def\a{\pscalculate{(1+sqrt(5))/2}}

\begin{document}
$0\foreach \i in {1,...,10}{,\psCalculate[round-mode=places,round-precision=0]{\q*((\a)^(\i)-(1-\a)^(\i))}}$
\end{document}

enter image description here


Fibonacci with simple LaTeX commands:

\documentclass{article}
\usepackage{ifthen}
\newcounter{fiba}\newcounter{fibb}\newcounter{fibc}\newcounter{fibrun}
\newcommand\fib[1]{%
  \init\whiledo{\thefibrun<#1}{\step\stepcounter{fibrun}}\thefiba}
\newcommand\init{%
  \setcounter{fiba}{1}\setcounter{fibb}{1}\setcounter{fibrun}{0}}
\newcommand\step{\add \rotate}
\newcommand\add{\setcounter{fibc}{\thefiba}\addtocounter{fibc}{\thefibb}}
\newcommand\rotate{\setcounter{fiba}{\thefibb}\setcounter{fibb}{\thefibc}}

\begin{document}
  \newcounter{i} \newcounter{en} \setcounter{en}{20}
  the first \theen\ Fibonacci numbers:\\
  \whiledo{\thei < \theen}{$\fib{\thei}$ \stepcounter{i}}
\end{document}

enter image description here

and the same with running lualatex:

\documentclass[12pt,a4paper]{article}
\usepackage{luacode}
\begin{luacode*}
function printFib(n)
  for i=1,n do tex.print(Fibonacci(i).." ") end
end
function Fibonacci(n)
  local function inner(m)
    if m < 2 then return m end
    return inner(m-1) + inner(m-2)
  end
  return inner(n)
end
\end{luacode*}

\begin{document}
\noindent\directlua{printFib(35)}
\end{document}

enter image description here


mwe

Someone should create a rlatex compiler at once, but meanwhile, I will settle with the knitr preprocess. Here the .Rnw file:

\documentclass[12pt,border=1cm]{standalone}
\begin{document}
<<Fib,echo=F>>=
Fibonacci <- function(n) {
    x <- c(0,1)
    while (length(x) < n) {nth <- length(x)
        new <- x[nth] + x[nth-1]
        x <- c(x,new)}
    return(x)}
@
\Sexpr{combine_words(Fibonacci(11))}.
\end{document}