How can we see that Dirichlet's function
$$D(x):=\lim_{m\to\infty} \lim_{n\to\infty} \cos^{2n}(m!\pi x)= \begin{cases} 1 & x\in\mathbb Q\\ 0 & x\notin\mathbb Q\\ \end{cases}$$
How can we see that Dirichlet's function
$$D(x):=\lim_{m\to\infty} \lim_{n\to\infty} \cos^{2n}(m!\pi x)= \begin{cases} 1 & x\in\mathbb Q\\ 0 & x\notin\mathbb Q\\ \end{cases}$$
For $x$ rational there is such (large enough) $m$, that $m!$ contains as divisors all divisors of the $x$ denominator, so $m!x$ is integer. (EDIT Actually for $x=\tfrac pq$ having $m\ge q$ is enough, since $q$ becomes explicitly one of the terms in $m!$ product.) This guarantees cosine being $+1$ or $-1$. When raised to any positive even power ($2n$) it results in $1$.
OTOH for $x$ irrational, there is no such natural $m!$ which makes $m!x$ integer, so cosine will be less than $1$ (in absolute value). Thus raised to a power big enough it approaches zero, so the limit is $0$.