Closed form expression for modulo function? I wonder if there is a closed form expression that returns the values of modulo function for integers $(n \mod m)$? I mean, the modulo operation is not really analytic since one chops off the number after division. But maybe there is a continuous periodic function that is equal to mod at integer input values?

Remark that for reals variables $\quad\displaystyle{n \mod m=n-\lfloor \frac nm\rfloor\times m}$
So for $m$ fixed the function $x:\mathbb R\to \mathbb R$ with $f(x)=x\mod m$ is piecewise continuous since the $floor$ function is periodic and continuous inside its period interval.
This is the blue curve below ($m=5$).
You should not be surprised of that, we use it everyday in trigonometry when we talk about angles $\theta$ modulo $2\pi$, the angle $\theta$ is a real value, and so is $2\pi$.

The other function for $n$ fixed $x:\mathbb R\to \mathbb R$ with $f(x)=n\mod x$ is not so nice, it is also piecewise continuous but not periodic anymore and the behaviour near $0$ is dreadful. This is the red curve ($n=5$).

Now you can visualize how to make $f$ (the blue curve) completely continuous: instead of the vertical bars (which are discontinuities and artefacts of drawing application), use a segment to join $y=4$ to the next $y=0$ then the function becomes piecewise linear and continuous.
$\begin{cases}
x\in[mk,mk+(m-1)]\qquad\qquad f(x)=x-m\lfloor\frac xm\rfloor\\
x\in[mk+(m-1),m(k+1)[\quad\ \  f(x)=(m-1)(m-x+m\lfloor\frac xm\rfloor)
\end{cases}$
Should be ok, but it doesn't really respect the modulo in the interval $[mk+m-1,mk+m]$.
Instead it is possible to convolute $f$ with a smooth function in the interval $[mk-\varepsilon,mk+\varepsilon]$ to get a completely $C^\infty$ function with $\lim\limits_{x\to km^-}f(x)=m$ and $\lim\limits_{x\to km^+}f(x)=0$. (a bit abusive language when talking about limits, but you understand the pinciple).
