I am reading "Measure, Integration & Real Analysis" by Sheldon Axler.
The following exercise is Exercise 30 on p.40 in Exercises 2B in this book.
Exercise 30
Show that $$\lim_{j\to\infty}\left(\lim_{k\to\infty} \left(\cos(j!\pi x))^{2k}\right)\right)=\begin{cases} 1 & \text{ if }x\text{ is rational},\\ 0, & \text{ if }x\text{ is irrational} \end{cases}$$ for every $x\in\mathbb{R}.$
[This example is due to Henri Lebesgue.]
My solution is here:
Let $x\in\mathbb{Q}.$
Then, we can write $x=\pm\frac{p}{q}$, where $p$ and $q$ are positive integers and $\gcd(p,q)=1.$
$(q+2)!(\pm\frac{p}{q})=\pm(q+2)(q+1)(q-1)!p$ is even because $q+2$ or $q+1$ is even.
So, if $q+2\leq j$, then $\cos(j!\pi(\pm\frac{p}{q}))=1.$
So, $\lim_{k\to\infty} \left(\cos(j!\pi x)\right)^{2k}=1$ for $j\in\{q+2,q+3,\dots\}.$
So, $\lim_{j\to\infty}\left(\lim_{k\to\infty} \left(\cos(j!\pi x)\right)^{2k}\right)=1.$
Let $x\in\mathbb{R}\setminus\mathbb{Q}.$
Then, $-1<\cos(j!\pi x)<1$ for any $j\in\{1,2,\dots\}.$
So, $\lim_{j\to\infty}\left(\lim_{k\to\infty} \left(\cos(j!\pi x)\right)^{2k}\right)=\lim_{j\to\infty} 0=0.$
I wonder why the author (or Henri Lebesgue) didn't write $$\lim_{j\to\infty}\left(\lim_{k\to\infty} \left(\cos(j!\pi x))^{k}\right)\right)=\begin{cases} 1 & \text{ if }x\text{ is rational},\\ 0, & \text{ if }x\text{ is irrational} \end{cases}$$ for every $x\in\mathbb{R}.$