Question: How to show that:

$$f(x)= \lim\_{k \to \infty} \Bigl(\lim\_{j \to \infty} \cos^{2j}(k!\cdot \pi \cdot x)\Bigl)$$

is the *Dirichlet's function*.

Answer: 
Suppose $x = \frac {p}{q} \in \mathbb{Q}$. If $k>q$ then $k! \cdot x \in \mathbb {Z}$ so $ \cos(k!\cdot \pi \cdot x) = \pm 1$
$$ k>q,\; \; \lim\_{j \to \infty} \cos(k!\cdot \pi \cdot x)^{2j} = \lim\_{j \to \infty} (\pm 1)^{2j} = 1$$

so taking the limit of $k \rightarrow \infty$ you get also 1.

If $x \notin \mathbb{Q}$ then for every k we have $k! \cdot x \notin \mathbb {Z}$ so $ |\cos(k!\cdot \pi \cdot x)| < 1$ therefore

$$ \lim\_{k \to \infty} \lim\_{j \to \infty} \cos(k!\cdot \pi \cdot x)^{2j} = \lim\_{k \to \infty} 0 = 0 $$
If x is rational, once k gets large enough the cosine is 1 independent of j. If x is irrational, the cosine is less than one so the j limit will be zero. This is true for all k.