Solve equation of a sum containing round operator

55 Views Asked by At

I need to get some integer values (that is why I'm using the rounding operator $[x]$) that when added together yield a zero.

I start with an array of $a$ values ($n$ is finite, it can be $n = 10$ for instance) that are real values, and then there is this $x$ variable (a real number also) that I want to get the solution that satisfies this equation: $$\sum_{i=1}^{n}{[a_i-x]} = 0$$ I have been solving this problem with an iterative "method", but there has to be some better way to solve this... right?

Edit: The "iterative method" I was talking about just consists in plugging a value of $x$, calculating the result and it is $0$ then the process ends, if it is $>0$ then I plug a smaller value of $x$ and if it's $<0$ then $x$ is increased.

Thanks to everybody in advance!