Here's my approach to check numbers, using modular arithmetic.
(\frac{[x-x\, mod\,10^{2}]}{10^{2}}+x\, mod\,10^{2}=\frac{x\, mod\,10^{3}-x\, mod\,10}{10})
Basically, if x is the number, and it is written as abcd, the first term is ab, the second term is cd, and the right side is bc.
If we want to generate such a number, in the realm of 4-digit numbers, simply realize that the the middle digits can go from 0 to 99. Therefore, if the number x is of the form abcd, we can generate numbers using the following algorithm:
1. Pick bc. We have one constraint: c must be less than or equal to b. If c is larger than b, ab+cd>bc always, since the second number we're adding is clearly larger than bc.
2. Now we find the second constraint, that is:
(ab+cd=\left[a*10+\frac{(bc-bc\, mod\,10)}{10}\right]+\left[(bc\, mod\,10)*10+d\right]=bc)
Or more simply:
(100a+10d=9*(bc-11*bc\, mod10))
Since we are generating numbers, this is our main goal. We know exactly how our unknowns relate to the middle number bc.
Now it is simple:
3. Pick d as follows:
(d=\frac{9}{10}*(bc-11*bc\, mod10)\, mod10)
4. Pick a as follows:
(a=[9*(bc-11*bc\, mod10)-10*d]/100)
If you generate b and c separately, simply let (bc-11*bcmod10)=(b-c)*10. This simplifies everything a little bit, we get:
3. Pick d as follows:
(d=[9*(b-c)]\, mod10)
4. Pick a as follows:
(a=[9*(b-c)-d]/10)
By the way, it's impressive that once the middle two digits are chosen, the rest of the number is defined. I initially thought that there were going to be several cases, but there aren't. This is obviously equivalent to Bob's, but I only read his post after finding my solution.
There you have it.