Sum of Floor of Square Root: $S = \sum_{k=1}^{n} \lfloor \sqrt{k}\rfloor$

$$S = \sum_{k=1}^{n} \lfloor \sqrt{k}\rfloor.$$

Hello, I´m trying to solve this summation. I was able to get $$a_n = 2a_{n-1} - a_{n-2}$$ for non perfect square numbers and $$a_n = 2a_{n-1} - a_{n-2} + 1$$ for perfect square numbers. But I´m clueless how to continue. I was thinking about some function which is 1 for square numbers and 0 for others and and make only one recurrence. But I don´t think that´s the way...