Quote:

How could I construct a function which relate an argument and a value this way?

. . $\displaystyle \begin{array}{c|ccccccccccccccccc}

x & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & \cdots \\ \hline

y & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 5 & 4 & 3 & 2 & 1 & 0 & 1 & 2 & 3 & \cdots \end{array}$

This is obviously periodic function, so I can write: .$\displaystyle f(x)\:=\:f(x+12)$

but how could I give a comprehensive formula for $\displaystyle \,y$?

Should I write piecewise definition, or recursive, or ... ?