# 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

-