The x-th triangular number (the triangular number which has x as its subscript) is:
T(x) = 1 + 2 + 3 + ... + x
Which we can also write as:
T(x) = x*(x+1)/2
So to answer our question we have to solve the following equation:
2*T(x) + x = 24
Which, after rewriting using the aforementioned formula, ultimately yields the quadratic equation:
x² + 2*x - 24 = 0
With x = 4 as its only positive root.
Note that we didn't need the condition on the difference between the two numbers, but our solution indeed satisfies it, in fact we have x = 4 and so T(x) = 10, and 10 - 4 = 6.