Variable in upper bound of sum

Given your comment that you want the upper bound to be the integer closest to $0.9\over x$, the problem can be stated as finding $x$ such that $$\sum_{n=0}^{a(x)} (1-nx) = 45,$$ where $a(x)=\left[{0.9\over x}\right]$ and $[.]$ is the nearest integer function. Now $$\begin{align}\sum_{n=0}^a (1-nx) &= \sum_{n=0}^a 1- \sum_{n=0}^a nx\\ &=\sum_{n=0}^a 1- x\sum_{n=1}^a n\\ &=(a+1) -x\,{a(a+1)\over 2} \end{align}$$

where we've used the formula $\sum_{n=1}^a n={a(a+1)\over 2}$, which Carl Friedrich Gauss supposedly found in his youth (although it was known long before that).

So, we want to solve for $x$ in the following equation: $$(a(x)+1) -x\,{a(x)(a(x)+1)\over 2} = 45.\tag{1}$$

Approximate solution

An approximate solution can be obtained easily by solving equation (1) with $a(x) = {0.9\over x}$ (rather than the nearest integer), yielding $x\approx 0.011136\ldots.$ To find out how good this approximation is, we now obtain the exact solution.

Exact solution

Rearranging equation (1), we get $$x = 2{a(x)-44\over a(x)(a(x)+1)}\tag{2} $$

which provides two observations:

  1. A solution $x$ (if it exists) must be a rational number, because the RHS of (2) is a ratio of integers.
  2. Fixed-point iteration converges to an exact solution, e.g. if we start with $x_0=0.01$ (say): $$x_{n+1} = 2{a(x_n)-44\over a(x_n)(a(x_n)+1)},\quad n=0,1,2,\ldots $$

Thus,

n     x_n
--    -------
0     1/100 
1     46/4095 
2     1/90
3     37/3321
4     37/3321 
...   ...

giving the exact solution $$x={37\over 3321}=0.\overline{011141222523336344474555856669677807889190003}$$ where the overline indicates the period of the repeating decimal digits.


Here's a plot from Wolfram Alpha showing the exact LHS of equation (1) in blue and the approximated LHS in orange. The solution in each case is the $x$-coordinate where the curve intersects the horizontal line with ordinate $45$: enter image description here

NB: You were right to be concerned with the possibility that a solution might not exist, although it happens that the value $45$ is a fortunate choice. As the above plot shows, there would be no solutions for values that correspond to the infinitely many "gaps" where discontinuities occur (e.g., in the neighborhood of $45.4$ or $44.8$, say).


This is mostly a comment on the fine answer by r.e.s.

As r.e.s. shows, if $a$ is the nearest integer to $9\over10x$, then

$$x=2{a-44\over a(a+1)}$$

That is, we are looking for (positive) integer solutions to

$${9a(a+1)\over20(a-44)}=a+r$$

with $|r|\le{1\over2}$. (There is a potential ambiguity if there is a solution with $|r|={1\over2}$, but we'll see that this doesn't occur.) This can be rewritten as

$$-10\le{a(889-11a)\over a-44}\le10$$

For $a\gt44$, these inequalities becomes

$$11a^2-899a+440\lt0\lt11a^2-879a-440$$

while for $a\lt44$ the inequalities signs are reversed. This gives two intervals in which to look:

$$\left({879+\sqrt{879^2+44\cdot440}\over22},{899+\sqrt{899^2-44\cdot440}\over22} \right)\approx(80.40656,81.23487)$$

and

$$\left({879-\sqrt{879^2+44\cdot440}\over22},{899-\sqrt{899^2-44\cdot440}\over22} \right)\approx(-0.49747,0.492399)$$

The first interval contains the relevant integer value $a=81$, with the corresponding value $x=2(81-44)/(81\cdot82)=37/3321$. The second interval contains only the irrelevant integer value $a=0$. We thus see that the solution found by r.e.s. is unique.