# Number theory question with floor function

Define $[a]$ as the largest integer not greater than $a$. For example, $\left[\frac{11}3\right]=3$. Given the function $$f(x)=\left[\frac x7\right]\left[\frac{37}x\right],$$ where $x$ is an integer such that $1\le x\le45$, how many values can $f(x)$ assume?

A. $1$ B. $3$ C. $4$ D. $5$ E. $6$

I have attempted this question by brute force however I am looking for a cleaner, more systematic approach.

First, $f(x) \le \left[\frac{x}{7}\cdot\frac{37}{x}\right] = 5$, and $f(x) \ge 0$. Therefore, $f(x)$ can assume a maximum of $6$ values: $0,1,2,3,4,5$.

Second, $f(x)=1$ implies $\left[\frac{x}{7}\right]=1$ and $\left[\frac{37}{x}\right]=1$. The first condition implies $7 \le x \le 13$, while the latter requires $19 \le x \le 37$, which is impossible. So $f(x) \neq 1$.

Checking first few values of $x$ reveals that $f(x)$ can assume the values $2,3,4,5$. Specifically, for $1 \le x \le 6$, we have $f(x)=0$ as $[x/7]=0$. For $x=7$, $f(x) = 5$; for $x=8,9$, $f(x)=4$; for $x=10, 11, 12$, $f(x)=3$, and for $x=13$, $f(x)=2$.

Consequently, the number of values $f(x)$ can assume is $5$.

We start from $x=1$ and work up. At this point, the left floor function returns zero so $f(x)=0$.

• This continues until $x=7$, whereupon the left floor is 1 and the right floor is 5, so $f(x)=5$.
• $\lfloor37/8\rfloor$ and $\lfloor37/9\rfloor$ are 4; $\lfloor37/10\rfloor$ to $\lfloor37/12\rfloor$ are 3; $\lfloor37/13$ is 2. In all these cases the left floor expression is 1, so $f(x)=4,3,2$.
• At $x=14$ the left floor becomes 2. The right floor remains 2 ($f(x)=4$) until $x=19$ when it becomes 1 ($f(x)=2$).
• At $x=21$ the left floor becomes 3 ($f(x)=3$). The right floor remains 1, continuing through $x=28$ ($f(x)=4$) and $x=35$ ($f(x)=5$) to $x=37$, when the right floor reaches 0 and $f(x)=0$ for the remaining values of $x$ (to 45).

We find that $f(x)$ may assume the values $0,2,3,4,5$ – five distinct values. The answer is D.