TITLE: How many distinct values of floor(N/i) exists for i=1 to N.
QUESTION [10 upvotes]: Say we have a function $F(i)=\text{floor}(N/i)$.
Then how many distinct values of $F(i)$ will exist for all $0 \leq i \leq N$
e.g. We have $N=25$ then.
$F(1)=25$
$F(2)=12$
$F(3)=8$
$F(4)=6$
$F(5)=5$
...
...
...
$F(24)=1$
$F(25)=1$
So total distinct values of $F(i)$ are $(N=25)$ :- $25, 12, 8, 6, 5, 4, 3, 2, 1$
total distinct values are $9$: $(2 \times 5-1)$
Can anyone please help in that total number of distinct values are $O(\sqrt{N})$?

REPLY [2 votes]: Let $k = \left\lfloor{\frac{N}{i}}\right\rfloor$. Take two cases -

$k \le \sqrt{N}$: Clearly there are $\mathcal{O}(\sqrt{N})$ possible values for $k$ in this case
$k > \sqrt{N}$: In this case $i \le \sqrt{N}$. Since there are $\mathcal{O}(\sqrt{N})$ possible values for $i$, there are $\mathcal{O}(\sqrt{N})$ values for $k$ as well.

$\implies$ the maximum distinct values of $k$ is $\mathcal{O}(\sqrt{N})$