12,21,....,122222222 are the required numbers we can assume all of them to be nine-digit in the form of a1,a2,a3,a4,a5,a6,a7,a8,a9 and can use 0 for a1;a2 and a0 and a0,a1,a2,... and so on to get 8 digit, 7, digit numbers etc. a1 can assume one of the 2 values of 0 or 1.a2,a3,a4,a5,a6,a7,a8 can assume any of the three values 0,1,2.
The number for which a1=a2=a3=a4=a5=a6=a7=a8=a9=0 must be eliminated. The sum of first 8 digits i.e. a1+a2+a3+a4+a5+a6+a7+a8 can be in the form of 3n−2 or 3n−1 or 3n. In each case a9 can be chosen from 0,1,2 in only 1 way so that the sum of all 9 digits is equal to 3n.
∴ Total numbers =2×37×1−1=4374−1=4373
Sum of digits is 17