How to evaluate $ \int_0^n \cos(2\pi \lfloor x\rfloor\{x\})dx$? For a real number $ x$, let $\lfloor x\rfloor$ denote the largest integer less than or equal to $x$ and $ \{x\}=x-\lfloor x\rfloor$ (floor and fractional part, resepectively). Let $n$ be a positive integer. I want to evaluate$$ \int_0^n \cos(2\pi \lfloor x\rfloor\{x\})dx$$
I broke down the integral as
$$\int_0^1\cos(2\pi \cdot 0 \cdot x)dx+\int_1^2\cos(2\pi \cdot 1 \cdot x)dx +\cdots+ \int_{n-1}^{n}\cos(2\pi \cdot (n-1)\cdot x)dx$$
However I got the wrong answer and I couldn’t understand where I went wrong.
 A: The interval $[0,1]$ brings a contribution $$\int_0^1dx=1$$ while all others integrate the cosine over an integer number of periods !
A: Here are some hints only, since you did not provide any effort: 
I assume that $n$ is a positive integer. I suggest that you divide your integral as
$$
\sum_{k=1}^n\int_{k-1}^k\cos\bigl(2\pi[x](x-[x])\bigr)\,dx.
$$
Then use that, in the integral from $k-1$ to $k$, $[x]=k-1$. Insert this. Then, use the periodicity of cosine, and you will find that only one of the integrals (for what $k$?) is non-zero. A very simple calculation shows that the non-zero integral equals $1$.
For this question, a graph could be useful. The case $n=5$ is attached below.

A: Here is to complete the ideas of the OP. I am surprised there are not many answers to this relatively old question.
Splitting the interval $[0,n]$ as $[0,n]=[0,1]\cup(1,2]\cup\ldots\cup(n-1,n]$ as the OP does the trick.
The first term in the OP's splitting
$$\int_0^1\cos(2\pi \cdot 0\cdot x)dx+\int_1^2\cos(2\pi x)dx +\cdots+ \int_{n-1}^{n}\cos(2\pi (n-1)\cdot x)dx$$
is $\int^1_0\,dt=1$. Each of the remaining terms is $0$
$$
\int^{k+1}_k\cos(2\pi k x)\,dx =\frac{1}{2\pi k}\sin(2\pi k x)\big|^{k+1}_k=0
$$
