Is there any way we can find all the values of x in O(log) or O(1) time complexity.
X + X%5 = 1000
The brute force approach is thinking and putting different values of X and checking with RHS. But the things is I can't think of any other approach other than this for finding the value of X. Is there any other way we can actually find the value of X?
One solution is $X = 1000$. To find another solution, you only need to try values of $X$ in the vicinity of $1000$. For example, $\{999,998,997,996\}$. None of these satisfy the equation, so the solution is $X = 1000$. If the equation were $X - X\%5 = 1000$, then there would be solutions $X = \{1000,1001,1002,1003,1004\}$.
Extending this, the solution to $$X + X\%5 = 10^{18},$$ would be $X = 10^{18}$, and the solution to $$X-X\%5 = 10^{18}$$ would be $X = \{10^{18},1+10^{18},\dots,10^{18}+4\}$.