Can anyone please direct me to an algorithm/formulae that says how to calculate all variations of a digit sum with a certain upper limit
So for example, if my digit sum is 6 and the upper limit is 123, then all variations for that digit sum would be: 6, 15, 24, 33, 42, 51, 60, 105, 114 and 123.
The upper limit can be up to 10**18 and program needs to work in under 1 second(in C/CPP), so brute force is not an option.