I am completely new to optimization. I only know one method of optimization, i.e. optimization using the differentiation (without any constraint).

I am trying to find the optimal value of $x$. Note the following. $a \in \{1,1/4, 1/2, 3/4\}$ and $n$ is an integer such that $ 50 \leq n \leq 500$. $b$ is also an integer and $5\leq b \leq 44$

\begin{align}

f(x) = a\left(1-\dfrac{a}{x}\right)\left(1-\dfrac{a}{bx}\right)^{n-2}

\end{align}

\begin{align}

f'(x) = \dfrac{a^2\left(1-\frac{a}{bx}\right)^{n-2}}{x^2}+\dfrac{a^2\left(n-2\right)\left(1-\frac{a}{x}\right)\left(1-\frac{a}{bx}\right)^{n-3}}{bx^2}

\end{align}

letting $ f'(x) = 0$, we get

\begin{equation}

x = \dfrac{a(n-1)}{n+b-2} \ \ \ \ \ \ \ \ \ \ \ \ \ \ (1)

\end{equation}

Now $x $ is itself an integer and should be $5\leq x \leq 64$. But the roots of $x$ as shown in (1) does not give me the correct result.

How can I proceed?

PS. Example. If $a = 1/2, n = 100, b = 10$, then $x < 1$ and