Conventional Method:
1, 2, ..., 7, 8, ..., 17, ..., 27, ...37, ..., 47, ...., 57, ...., 67, ...., 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, ..., 87, ...., 97.., 100
The total count of 7 that we get is 20.
Alternate Method:
This can also be solved using Permutations and combination logic as shown:
1) Let us assume that the digit 7 is only in the units place. The tenths place takes all digits except 7, i.e. _ 7
Number of combinations possible is 9 x 1 = 9
2) Let us assume the digit 7 is only in the tenths place. The units place takes all digits except 7, i.e. 7 _
Number of combinations possible is 1 x 9 = 9
3) Let us assume the digit 7 is in both units and tenths place, i.e. 77
Number of combinations possible is 1 x 1 = 1
Adding all the combinations 9 + 9 + 1 =19.
This is the total number of ways in which there is at least one 7.
Now since ‘77′ has two 7s., thetotal number of ‘7’ that has occurred is 19 + 1 = 20.