# Solve $\int_{2}^{341} \left(x - \lfloor x \rfloor \right)^2$

The question is $$\int_{2}^{341} \left(x - \lfloor x \rfloor \right)^2$$.

I understand how to solve integrals of floor functions (they get converted to discrete integrals) and even just this part: $$(x - \lfloor x \rfloor)$$.

I drew the graph and they're just 341 triangles with base 1 and height 1. so the answer is $$\frac{341}{2}$$.

How does one solve the square part? The answer given is $$\frac{341}{3}$$.

• Calculate the integrals from $2$ to $3$, $3$ to $4$,...,$340$ to $341$. – Kavi Rama Murthy May 1 at 10:08
• Please try to format your posts with MathJax. – StubbornAtom May 1 at 10:17

If $$x=n+u$$ where $$n\in\mathbb{Z}$$ and $$u\in[0,1)$$, then $$(x-\lfloor x\rfloor)^2=u^2$$.
$$\int_n^{n+1}(x-\lfloor x\rfloor)^2dx=\int_0^1u^2du=\frac{1}{3}$$
$$\int_2^{341}(x-\lfloor x\rfloor)^2dx=\sum_{k=2}^{340}\int_n^{n+1}(x-\lfloor x\rfloor)^2dx=\frac{339}{3}=113$$