# Continuous formula for a special piecewise function

I'm looking for a continuous function $$f(n, k)$$ such that when $$n, k \in \mathbb{N}$$,

$$f(n, k) = \begin{cases} 1, & k\mid n \\ 0, & k\nmid n \\ \end{cases}$$

For example, we can define $$f(n, 2) = \frac{(-1)^{n}+1}{2}$$. I'm not sure how this would work for $$k > 2$$ however; I was thinking maybe a clever composition of sine functions, or using $$e^{i \theta}$$ (kind of the same thing I guess), or even using the decimal expansions of $$\frac{1}{9}, \frac{1}{99},$$ etc. I couldn't quite get it however, and I'd appreciate if anyone could help!