An integer valued function that generate repeating integer for n amount of times in algebraic expression Recently I've made this function $f(x)=\frac{x+\frac{(-1)^x-1}{2}}{2}$ or $f(x)=\frac{2x+(-1)^x-1}{4}$ where $x$ is an integer. And it generate integers repeated two times, such as: $...,-3,-3,-2,-2,-1,-1,0,0,1,1,2,2,3,3,...$
So the question is: Is there any function where it could repeat itself for $n$ number of times? Like 3 times, $...,-3,-3,-3,-2,-2,-2,-1,-1,-1,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,....$
Although knowing the function is $f(x)=\frac{2x+(-1)^x-1}{4}$ , I could derive a function that repeats the integer for $2^n$ times by putting the output of the function $f(x)$ into the function $f(x)$ again, or like $f(f(x))$ and $f(f(f(x)))$ and so on.
Edit: I forget to add that I only know middle school math, if there are any formula that only use algebraic expression that would be helpful.
 A: One relatively simple function using integer $x$ inputs to get each integer repeating itself $n$ times in the output is using the floor function to get
$$f(x) = \left\lfloor \frac{x}{n} \right\rfloor \tag{1}\label{eq1A}$$
Alternatively, another function you can use is the ceiling function, with the output values shifted to the left $n - 1$ positions compared to the results of \eqref{eq1A}, to instead get
$$f(x) = \left\lceil \frac{x}{n} \right\rceil \tag{2}\label{eq2A}$$
A somewhat convoluted method is to use a piece-wise function, e.g., to get the same output as \eqref{eq1A}, use
$$f(x) =
\begin{cases}
m, & \text{if } x = mn, \; m \in \mathbb{Z} \\
m, & \text{if } x = mn + 1, \; m \in \mathbb{Z} \\
m, & \text{if } x = mn + 2, \; m \in \mathbb{Z} \\
\; \vdots & \; \; \; \; \; \; \; \; \; \; \; \; \; \vdots \\
m, & \text{if } x = mn + n - 1, \; m \in \mathbb{Z}
\end{cases}
\tag{3}\label{eq3A}$$
A: The following function should do the job:$$f(x) = \left\lfloor \frac x3 \right\rfloor $$
where $\lfloor x\rfloor$ is the greatest integer less than or equal to $x$.
(Also, see floor and ceiling functions for more information)

Note that, your function could also be written in fancy way as
$$f(x)=\frac{2x+(-1)^x-1}{4} = \left\lfloor \frac x2 \right\rfloor$$
since when $x$ is even the numerator is divisible by $4$, and when $x$ is odd the numerator gives remainder of $2$ when divided by $4$ so you subtract $2$ to make it divisible by $4$

Therefore, this function can easily be generalized by just adjusting the denominator of the floor function.
