How many numbers of 4 digits contains at least one “5”?

How many numbers of $4$ digits contains at least one "$5$"?

My suggestion is:

First I count all the numbers of type 5xxx (where x can be a number between 0 and 9). There is 999.

Then I add all the numbers of type y5xx (where y can be 1, 2, 3, 4, 6, 7, 8, 9). There is 8*99

Then I add all the numbers of type yz5x (where z can be 0, 1, 2, 3, 4, 6, 7, 8, 9). There is 8*9*9

Then I add all the numbers of type yzz5. There is 8*9*9

Total: 999+8*99+8*9*9+8*9*9 = 3087

My problem is, I'm not sure if this is correct OR if there exist a smarter method.

-
Have you had any thoughts? Can you start with how many between $1000$ and $1999$ have at least one $5$? Maybe counting by hand from $1000$ to $1099$ will give some ideas. – Ross Millikan Sep 27 '11 at 20:12
Welcome to MathSE. I see that this is your first question. So I wanted to let you know a few things about MathSE. Posting questions exactly as they appear in a homework, or in the imperative (i.e. Compute all such, Prove that...), is considered rude by some of the members, so it would be nice of you to change that wording; perhaps by adding what are your thoughts or what you have tried in trying to answer the problem. These sort of pleasantries usually result in more and better answers. Thank you. – Arturo Magidin Sep 27 '11 at 20:12
Ok. I will edit it with my suggestion. – user145 Sep 27 '11 at 20:15
There are several errors. Your first type is missing 000, so you should have 1000 numbers of the form 5rst (it's better not to use the same letter to represent several possibilities). The second type is likewise missing y500, so the answer should be $8\times 100$, not $8\times 99$. The third type is missing one as well. Other than the miscounts, you should be clearer: the first type consists of all numbers where the first occurrence of $5$ is in the first digit; the second the ones in which the first occurrence is the second digit; etc. Yes, it's a valid method. Sasha's is cleverer, though. – Arturo Magidin Sep 27 '11 at 20:28
@TheChaz: Since I stole^H^H^H^H^Hborrowed it from someone else (mixedmath, I believe), certainly! – Arturo Magidin Sep 27 '11 at 21:52

HINT: Compute how many 4 digit numbers contain no 5, and subtract that from the total count of 4 digit numbers.

-

Hint: it's easier to count how many have no 5's.

-

So as to give you an idea of how to do problems like this without doing your homework for you I will do a similar problem with a different answer. Maybe someone else will find it useful.

How many numbers with exactly four digits are there with at least one zero?

$9\cdot 10^3-9^4=9000-6561=2439$

Reason:

There are 9000 numbers with exactly 4 digits

(choices for each digit: 1 to 9,0 to 9,0 to 9,0 to 9)

There are 6561 numbers with 4 digits and no zeros

(choices for each digit: 1 to 9,1 to 9,1 to 9,1 to 9)

-

If first digit is 5 the rest can't be five 1*9*9*9

If the second digit is five the rest can't be five and the first can't be zero 8*1*9*9

If the third digit is five the rest can't be five and the first can't be zero 8*9*1*9

If the fourth digit is five the rest can't be five and the first can't be zero 8*9*9*1

So in conclusion, (1*9*9*9) + (8*1*9*9) + (8*9*1*9) + (8*9*9*1) = 2673

-
The 4 digit number could have multiple 5s and should still be counted, e.g. 1055 or 5555 should count but would be missed in your count. – JB King Jun 16 '15 at 15:18

First I count all the numbers of type 5xxx (where x can be a number between 0 and 9). There are 10*10*10=1000. Let this be A.

Then I add all the numbers of type y5xx (where y can be 1, 2, 3, 4, 5, 6, 7, 8, 9). There are 9*10*10=900. Let this be B.

Then I add all the numbers of type yz5x (where z can be 0, 1, 2, 3, 4, 5, 6, 7, 8, 9). There is 9*10*10. Let this be C.

Then I add all the numbers of type yzz5. There is 9*10*10=900. Let this be D.

So P(A)=1000;

P(B)=900;

P(C)=900;

P(D)=900;

P(A ∩ B)=100; //all numbers of type 55xx (where x can be a number between 0 and 9).

P(A ∩ C)=100; //all numbers of type 5x5x(where x can be a number between 0 and 9).

P(A ∩ D)=100; //all numbers of type 5xx5(where x can be a number between 0 and 9).

P(B ∩ C)= 90; //all numbers of type y55x(where x can be a number between 0 and 9 and y can be a number between 1 and 9).

P(B ∩ D)=90; //all numbers of type y5x5(where x can be a number between 0 and 9 and y can be a number between 1 and 9).

P(C ∩ D)=90; //all numbers of type yx55(where x can be a number between 0 and 9 and y can be a number between 1 and 9).

P(A ∩ B ∩ C)=10; //all numbers of type 555x(where x can be a number between 0 and 9).

P(A ∩ B ∩ D)=10; //all numbers of type 55x5(where x can be a number between 0 and 9).

P(A ∩ C ∩ D)=10; //all numbers of type 5x55(where x can be a number between 0 and 9).

P(B ∩ C ∩ D)=9; //all numbers of type y555(where y can be a number between 1 and 9).

P(A ∩ B ∩ C ∩ D)=1; // this is 5555

so

P (A U B U C U D ) = P (A ) + P (B ) + P (C ) + P (D ) - P (A ∩ B ) - P (A ∩ C ) - P( A ∩ D )- P (B ∩ C ) - P ( B ∩ D ) - P (C ∩ D ) + P (A ∩ B ∩ C ) + P (A ∩ B ∩ D ) + P (A ∩ C ∩ D ) + P (B ∩ C ∩ D ) - P ( A ∩ B ∩ C ∩ D )

which numerically is

P (A U B U C U D ) = 1000 + 900 + 900 + 900 - 100 - 100 - 100 - 90 - 90 - 90 + 10 + 10 + 10 + 9 - 1

=3168

-