Tuesday, July 27, 2021

2021/056) Let S(n) be the sum of digits of a number. Find the number of 3 digits numbers whose $S(S(n)) = 2$

Sum of all the digits of a 3 digit number that is $S(n)$  shall be between 1 and 27.

because $(S(n)) = 2 $ and $S(n)$ is between 1 and 27 so we have $(n) \in \{ 2,11,20\}$ 

Now the number of 2 digit numbers(with leading zero)  sum = n is n+1 for n $<=9$

This is so because 1st digit can be 0 to n and 2nd digit can be 2-n ( n = 0 or 1) or 11 -n ( n= 2 to 9)

The number of 1/2 digit numbers sum = n is 19-n for 9 < n < 19 is 19-n. 

This is so because the 1st digit can go from  n -9 to 9 or 9-(n-9) 

One digit number is allowed ( that is 2 digit number with leading zero)  because we are considering the tens digit of the 3 digit number that can be zero.

Now we shall use the above 2 do the counting

The 3 digit numbers that have sum 3 are 101,110,200 that is 3 numbers

let us count the number of 3 digit that have a sum 11

1st digit is 1 so sum of other 2 digit 10 so number of numbers = 19-10 = 9

1st digit is 2 to 9  so sum of other 2 digit 9 down to 2  number of numbers = $10 + 9 + \cdots 3 = \frac{(10 + 3)*8}{2} = 52$


So the number of numbers that have sum 11 is 9 + 52 = 61


let us count the number of 3 digit that have a sum 20


1st digit can be from 2 to 9 and that shall give the sum of other 2 digits of the number can be from 18 down to 11. the number of numbers can be 19-k with k from 18 to 11


so the sum = $1+2 + \cdots 8 = \frac{8 * 9}{2} = 36$


So total number of numbers with sum 20 = 36


So total number of numbers  = 3 + 61+ 36 = 100

 

No comments: