How many unique integers to be obtained by $\left\lceil\frac{F}{1:1:N}\right\rceil$?

57 Views Asked by At

Assume that $F$ and $N$ are positive integers, and $N<F$. How many unique integers would I get if I apply the ceiling function to the division of $F$ divided by $1,2,\ldots,N$, respectively. That is, I want a formula to (approximately) count $\mathrm{\texttt{length}}(\mathrm{\texttt{unique}}\left(\mathrm{\texttt{ceil}}(F./(1:1:N))\right))$, which is expressed in Matlab language.

1

There are 1 best solutions below

3
On BEST ANSWER

Let $g_f(n)=\left\lceil \frac{f}{n}\right\rceil$. We may first look at the forward difference of $g_f$, which is $\Delta[g_f](n)=g_f(n+1)-g_f(n)$. When $\Delta[g_f](n)\geq -1$ for all $n\geq n_0$, then $g_f(n)$ will take on all values from $g_f(n_0)$ to $g_f(f-1)=2$ when $n\geq n_0.$ Additionally, if $$f\left(\frac{1}{n_0+1}-\frac{1}{n_0}\right)= -1,$$ then for all $n\geq n_0$, $$f\left(\frac{1}{n_0+1}-\frac{1}{n_0}\right)\geq -1,$$ so $$\Delta[g_f](n)\geq -1.$$ We also note that if $$f\left(\frac{1}{n_0+1}-\frac{1}{n_0}\right)< -1,$$ then for all $n<n_0$, $$\Delta[g_f](n)< -1,$$ so every value of $g_f(n)$ is unique for all $n<n_0$. When we solve for $n_0$, we get $n_0^2 +n_0-f=0$, so $$n_0=\frac{-1+\sqrt{1+4f}}{2}.$$ However, $$0\leq\left\lceil\sqrt{f}\right\rceil-\left\lceil\frac{-1+\sqrt{1+4f}}{2}\right\rceil\leq 1.$$ So if we were to use $n_1=\sqrt{f}$ instead of $n_0$, the inequalities for $\Delta[g_f](n)$ would still hold. Thus, the number of unique values of $g_f(n)$ where $1\leq n<f$ is $$\lceil n_1\rceil-1+g_f(\lceil n_1 \rceil)-1=2\left\lceil \sqrt{f}\right\rceil -2.$$ Now the number of unique values of $g_f(n)$, where $1\leq n \leq N < f$ is $$\begin{cases}N & N<\left\lceil \sqrt{f}\right\rceil\\ 2\left\lceil \sqrt{f}\right\rceil -\left\lceil\frac{f}{N}\right\rceil & N\geq \left\lceil \sqrt{f}\right\rceil. \end{cases}$$ The first case comes from the fact that every value of $g_f(n)$ is unique for all $n<n_1$, and the second case comes from the fact that $g_f(n)$ will take on all values from $g_f(n_1)$ to $g_f(f-1)=2$ when $n\geq n_1,$ but we lose all the values from $g_f(N)-1$ and $2$ by the restriction $n\leq N$.