I want to let forest draw trees similar to following one automatically in a way, that changing the root of the tree will lead to the correct tree for this root.

The root is any natural number. The rule is child1=floor((parent-1)/2) and child2=floor(parent/2).
For now I wrote a Fortran-95 programm that produces some Forest code, that makes me able to produce such trees.
I would now like to do in a more elaborated way.
I found this code in another question and I think it is going in the right direction:
\begin{forest}
Stern Brocot/.style n args={5}{%
content=$\frac{\number\numexpr#1+#3\relax}
{\number\numexpr#2+#4\relax}$,
if={#5>0}{% true
append={[,Stern Brocot={#1}{#2}{#1+#3}{#2+#4}{#5-1}]},
append={[,Stern Brocot={#1+#3}{#2+#4}{#3}{#4}{#5-1}]}
}{}}% false (empty)
[,Stern Brocot={0}{1}{1}{0}{3}]
\end{forest}
But I am not able to understand how these #1,#2,... are working.

What i have right now is a small program that writes the tree in Forestsyntax into a file.
– tebartsch Jul 21 '17 at 17:28#1,#2,#3,#4and#5. In the example, these gets the values0,1,1,0and3respectively. – cfr Jul 21 '17 at 19:42