# Summation Closed form for floor$\left(\log_n\right)$

The closed sum for the floors of logs of consecutive integers is:

$$\sum_{i=0}^n \lfloor \log_2i\rfloor = n\lfloor \log_2n\rfloor-2^{\lfloor \log_2n\rfloor+1}+\lfloor \log_2n\rfloor+2$$

This formula works for $\log_2$, but I'm not sure how to adapt this to work for all bases.

I tried executing this and as you can see it works for base 2:

<?php

$sum = 0;$n = 200;

$base = 2; for ($i = 1; $i <=$n; $i++)$sum += floor(log($i,$base));