Definite integral of a function involving a floor function The function I am trying to integrate is
$\left(x - \lfloor x\rfloor\right)^2$
I am trying to integrate this from $0$ to $1000$.
I have figured out a few things. First,
$$
\int_0^N \lfloor x \rfloor^k\ dx = \sum_{n=1}^{N - 1} n^k
\text{,}$$
where $k$ is a fixed positive integer.
Thus,
$$
\int_0^N \left( x^2 -2 \lfloor x \rfloor + \lfloor x \rfloor^2\right)\ dx = 
\frac{1}{3}N^3 - 2 \sum_{i=1}^{N-1} n + \sum_{i=1}^{N-1} n^2
$$
At this point I should be able to plug and chug and get the correct answer, but my answer was way off. Wolfram gives the correct answer as $\frac{1000}{3}$. My answer was negative, and many orders of magnitude off.
What am I doing wrong? Did I get any details wrong?
 A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
Note that $\ds{\braces{x} \equiv x -\left\lfloor x\right\rfloor}$ is a periodic function of period $\ds{\color{red}{1}}$ and, in particular, $\ds{\braces{x} = x}$ when
$\ds{x \in \left[0,1\right)}$.

\begin{align}
&\bbox[5px,#ffd]{\left.\int_{0}^{N}\braces{x}^{k}\,\dd x
\,\right\vert_{N\ \in\ \mathbb{N}_{\ \geq\ 1}}} =
\sum_{n = 0}^{N - 1}\int_{n}^{n + 1}\braces{x}^{k}\,\dd x
\\[5mm] = &\
\sum_{n = 0}^{N - 1}\int_{0}^{1}
\braces{x + n}^{k}\,\dd x =
\sum_{n = 0}^{N - 1}\int_{0}^{1}\braces{x}^{k}\,\dd x \\[5mm] = &\
\sum_{n = 0}^{N - 1}\int_{0}^{1}x^{k}\,\dd x =
\sum_{n = 0}^{N - 1}{1 \over k + 1} = \bbx{N \over k + 1}
\\[5mm] &\ \mbox{For instance,}-----------------
\\ &\
N = 1000\ \mbox{and}\ k = 2 \implies
{1000 \over 2 + 1} = \bbx{1000 \over 3} \\ &
\end{align}
A: You aren't showing us all your calculations, but you could begin by checking $(x-\lfloor x \rfloor)^2 = x^2 -2 (\lfloor x \rfloor) + (\lfloor x \rfloor)^2$
