# Prove $\int_0^n \lfloor x\rfloor \,dx = \frac{n (n-1)}{2}$

Prove $\int_0^n \lfloor x\rfloor \,dx = \frac{n (n-1)}{2}, \text{ where$\lfloor x \rfloor$is the greatest integer less than or equal to$x$and$n \in \mathbb{Z}^+$.}$

I am working through Apostol's Calculus and if you know the text you know that he introduces integration before differentiation, so the idea of the antiderivative has not been introduced yet. I have graphed it out and I can see that:

$\int_0^n \lfloor x\rfloor \,dx = 0 (1-0 )+ 1(1-0) + ..+$

but I am having a hard time making the leap from here.

• Do you know how to sum $1+2+3+\dots+n$? – Wojowu Jan 6 '16 at 20:13
• You're so close . You observed that the integral is just : $$0+1+2+\ldots+(n-1)$$ so now prove that the sum is $\frac{n(n-1)}{2}$ . – user252450 Jan 6 '16 at 20:14
• Break it into a sum of integrals $\int_k^{k+1} dx\,\lfloor{x}\rfloor$. – anomaly Jan 6 '16 at 20:29

\begin{align}\int_0^n \lfloor x\rfloor\,dx &=\int_0^1 \lfloor x\rfloor\,dx + \int_1^2\lfloor x\rfloor\,dx + \cdots + \int_{n-1}^n\lfloor x\rfloor dx\\[10pt] &= \int_0^1 0\,dx + \int_1^2 1\,dx + \cdots + \int_{n-1}^n (n-1)\,dx\\[10pt] &= 0\Big|_0^1 + x\Big|^2_1 + \cdots + \big((n-1)x\big) \Big|_{n-1}^n\\[10pt] &= 0 + 1 + \cdots + (n-1) \\[10pt] &= \dfrac{n(n-1)}{2}\end{align}

• The second '$=$' is correct because function $\lfloor x \rfloor$ is defined as $\lfloor x \rfloor = \max\{ k \in \mathbb Z \colon k \leq x\}$.

So, as every integral is expressed from certain $w$ to $w+1$, it is true that $\forall w'\in [w, w+1)$, $\lfloor w' \rfloor = w$. That is, the image of every element in $[w, w+1)$ will be $\max\{ k \in \mathbb Z \colon k \leq w'\} = w$.

There is only an exception: $w' = w+1$. But no problem, because, by definition: $$\int_a^a f(x)\; dx = 0$$ In this case: $$\int_{w+1}^{w+1} \lfloor x \rfloor\;dx = 0$$

Hint: note that $$\int_0^n \lfloor x\rfloor \,dx = 0 + 1 + 2 + \ldots (n-1)$$ where the RHS is a well known sum.