This is a problem from a previous math competition. $a, b$ can be anywhere in the range $[1,10^9]$ ($a \le b$).
Edit: We can choose any subset of numbers from $a$ to $b$ to form a single sum. Each number cannot be used twice for the same sum.
For example, if $a = 2, b = 5$, then one possible sum is $2 + 4 + 5 = 11$.
The possible sums we can get range from $a$ up to $\frac{b(b+1)}{2} - \frac{a(a-1)}{2}$. I got this second number by using the formula $\sum_{i = a}^{b}{i} = \sum_{i = 1}^{b}{i} - \sum_{i = 1}^{a-1}{i} $. But still, this is a really large range to be brute-forced. For example, if $a = 1, b = 10^9$, then the range to be brute-forced would contain around $10^{18}$ numbers. How do I solve this? Any help would be much appreciated :)