I have a very simple equation which I need to do on a range of numbers as following:
(x/min)+(x/(min+1))+(x/(min+2))+...++(x/(max))
I have a variable called x which needs to be divided to a range of numbers from min to max and get the result of the addition of all the equations.
Currently I'm using a loop and it's working fine, but I am wondering how a similar problem is being solved with a single equation?
Provided that $min$ and $max$ are natural numbers, the formula you seek is $$x(H_{max}-H_{min-1})$$ where $H_n$ denotes the $n$-th Harmonic number, defined as $H_n=\frac{1}{1}+\frac{1}{2}+\cdots+\frac{1}{n}$.
If an approximation is good enough, $H_n\approx \ln n$, so a decent approximation to your desired sum is $$x(\ln max - ln(min -1))= x \ln \frac{max}{min -1}$$