[Math] For positive integers between 999 and 100 inclusive, how many contain the digit 5

combinatoricsinclusion-exclusion

The question comes in two parts:

  1. For positive integers between 999 and 100 inclusive, how many contain the digit 5 at least once?

  2. For positive integers between 999 and 100 inclusive, how many contain the digit 5 exactly once?


Question 1

Numbers between 999 and 100 inclusive:

999 – 99 = 900

Numbers between 999 and 100 inclusive that do not contain digit 5:

8 * 9 * 9 = 648 (The 8 is because the first digit can't be 5 or 0)

Numbers that contain digit 5 at least once:

900 – 648 = 252


Question 2

Total numbers that contain digit 5 exactly once:

(1*9*9) + (8*1*9) + (8*9*1) = 225


I think I got it wrong but not sure which part.

Best Answer

enter image description here

 There is one number with all three digits equal to 5.

 There are 1x10x10 = 100 numbers with the first digit equal to 5. 
 There are 9x1x10 = 90 numbers with the second digit equal to 5. 
 There are 9x10x1 = 90 numbers with the third digit equal to 5. 

 There are 10 numbers with the first and second digit equal to 5.
 There are 10 numbers with the first and third digit equal to 5.
 There are 9 numbers with the second and third digit equal to 5.

 There are 8x9x9 = 648 numbers with no digit equal to 5.

This is enough information to fill in the diagram above.