Thanks for the compliments guys!:)
gmatter81 wrote:Hi Rahul,
Request you to post the method for digits with zero as well. This will complete my understanding.
Thanks.
If the same question is asked without the "non-zero digits" constraint, then application of this method doesn't directly yield the answer. In that case we have to proceed in a little different way. (and tricky I must say

)
Let's take an question for analysis:
How many numbers which are less than 10000 are there such that sum of their digits is 10?
The numbers may be a two or three or four digit number. Let's represent the numbers in the same manner, i.e. each digit with '1's and separate each digit with '|'. Some possible numbers and their new representations are,
- 0082 --> ||11111111|11
0253 --> |11|11111|111
4231 --> 1111|11|111|1
7021 --> 1111111||11|1
Observe that total number of '1's is 10 as the sum should be 10 and total number of separators is 3 as maximum number of digits is 4 (3 separators needed to separate 4 digits). But unlike the previous case there is no constraint in placing the separators between the digits. They can be placed anywhere except a few, which we'll see later. Thus it's just a problem on arranging some items in which some are identical!
The problem can be rephrased as in how many ways ten '1's and three '|' can be arranged?
And the answer is, (10 + 3)!/(10!)*(3!) = 286
Tricky isn't it? But careful! The trick is not over yet!

I mentioned there are few limitation in placing the separators!
They can placed anywhere except all of them together at the leftmost or rightmost side! Because doing so will result in |||1111111111 begin_of_the_skype_highlighting              1111111111      end_of_the_skype_highlighting --> 000(10)! That means we have to treat 10 as a digit which is not possible. Same for 1111111111|||.
Thus correct number of numbers = 286 - 2 = 284
Therefore whenever the sum is a two digit number you have to take care of this problem.
Now going back to where we started, if the problem asks for
how many four digit numbers are there such that sum of their digits is 10?, the numbers of such numbers will be equal to (Such numbers with 2 or 3 or 4 digits - Such numbers with 2 or 3 digits)! Both of which can be obtained by the above described method!