Why is $D(x)$ periodic? Let $D(x)$ be defined as
$$D(x) =
\begin{cases}
1 & \text{if $x$ is rational} \\
0 & \text{if $x$ is irrational}
\end{cases}$$
Why is $D(x)$ a periodic function? It certainly doesn't look like $\sin(x)$ or $x-\lfloor x\rfloor$. Then why do people say it's periodic exactly?
 A: Any rational number is a period. Let $q$ be a rational number, then $D(x+q)=D(x)$ $\forall x$, because if $x$ -- rational, then $x+q$ -- rational. And if $x$ -- irrational, then $x+q$ -- irrational. 
A: Because$$(\forall x\in\mathbb R):D(x+1)=D(x).$$Is that a good enough reason?
A: A periodic function is a function returning to the same value at regular intervals. The period is not unique since for example sin(x)=sin(x+2npi) for any integer n. 
The function D(x) is 1 whenever x is rational and zero otherwise. Then let b be another rational number. As thing said x+b is also rational, since adding two fractions we get another fraction. Since x+b is rational then D(x)=D(x+b)=1 and finally since each integer is a rational number, since for integer n we can write n/1 we have D(x)=D(x+nb)=1. 
A: Another way of justifying that $D$ is periodic is to think of $D$ as two constant functions assigned by cases: $D_Q(x)=1$ for $x\in\mathbb{Q}$ and $D_I(x)=0$ for $x\notin\mathbb{Q}$. Both the rationals and irrationals are closed under addition by a rational, so both $D_Q$ and $D_I$ stay inside their domains when their argument is translated by a rational. But all constant functions are trivially periodic (albeit without a fundamental period). Therefore, so too are $D_Q$ and $D_I$ on their domains, with rational period, and so too is $D$.
