Drexel dragonThe Math ForumDonate to the Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Numbers with the Digit 3

Date: 10/27/1999 at 21:58:36
From: Namita
Subject: Permutations and combinations

The question that I'm having trouble with is this:

In how many numbers between 1000 and 9999 does the digit 3 occur?

I know that each number must be at most four digits, and that 3 can 
occur in all four places (units, tens, hundreds, and thousands), but 
there is no possible way to count them all. I can't figure out what 
formula could help me to solve this - am I looking for combinations or 

I'll appreciate any help you can give.

Thank you,

Date: 10/28/1999 at 03:49:16
From: Doctor Mitteldorf
Subject: Re: Permutations and combinations

Dear Namita,

There are no rules or formulas for problems like this. It's good to 
get used to the idea that in statistics problems and combinations 
problems you always want to go back to first principles and try to get 
a picture inside your head of what it is you're counting.

One way to do this is just to write a computer program to do the 
counting for you. It's an easy program to write if you know Pascal or 
Basic or C, and will take only a few minutes. It's a legitimate way to 
check your other method.

We'll have to invent the other method. Start with all the 3xxx 
numbers. There are just 1000 of them. Then, how many numbers have 3 
in the second digit? 100 each for 13xx, 23xx, 33xx, 43xx, 53xx, 63xx, 
73xx, 83xx and 93xx. But we've already counted the 33xx's when we 
counted the 3xxx's. So we have 800 new ones.

Can you continue with this kind of reasoning? It does get a bit more 
complicated when you have to think about what's excluded (because 
you've already counted it) in the steps that follow. The final answer 
I get is 3168.

- Doctor Mitteldorf, The Math Forum

Date: 10/10/2015 at 09:58:32
From: Ashley
Subject: Numbers between 1000 and 9999 containing the digit 3

Dear Dr. Math,

Since it could easily come up again in a similar form, may I take issue 
with the answer given to the old question, above?

Namita asked for a formula approach to count how many integers between 
1000 and 9999 contain the digit 3. Doctor Mitteldorf replied that "there 
are no rules or formulas for problems like this," then suggested first a 
computer program followed by an alternative "reasoning" approach that 
eventually leads to the correct answer 3168.

However, there is a much quicker formula-based method, as follows. 

The number of integers between 0 and 10^n - 1 which contain the digit 3 
(or any other specified single digit) is given by the formula

   f(n) = 10^n - 9^n

This is evident from treating all the integers as consisting of exactly 
n digits, including leading zeros where appropriate, and observing that 
while the total number of integers is 10^n, the number of digits without 
a 3 is 9^n since there are now only 9 digits to choose from each time. 
The total number of integers between 0 and 9999 is therefore f(4) = 3439, 
while the unwanted subset relating to the range 0 to 999 has f(3) = 271 
such integers. The answer is therefore 3439 - 271 = 3168.

Congratulations on an excellent site, which explains such a wide variety 
of problems in a very user-friendly style. I really enjoy picking up 
useful new ways to understand the familiar as well as the unfamiliar.

Kind regards,


Date: 10/10/2015 at 12:47:09
From: Doctor Peterson
Subject: Re: Numbers between 1000 and 9999 containing the digit 3

Hi, Ashley.

This is certainly a nice way to solve the problem, and you've explained 
it very clearly.

I would like to defend Dr. Mitteldorf's statement that "There are no 
rules or formulas for problems like this." His point, I think, was not 
that there are no applicable formulas at all, but that one should not 
approach these problems expecting to have an already-memorized formula 
that would apply immediately to the exact problem. 

It's also possible, though, that he missed the subject line 
"Permutations and combinations," and assumed the student was coming to 
the problem without those tools. (At some levels, what he did is exactly 
what would be expected, breaking the problem down into parts; and there 
are some similar-sounding problems for which that might be the only 
way.) Often the context is key to choosing a method, and I have often 
used a less than ideal method because either I missed an important clue 
about the intent of the problem, or the student didn't tell us enough of 
her background.

Note that your formula is not one that one needs to memorize, but can be 
easily derived on the fly from first principles, so it actually fits 
into what he was saying. It is, of course, far easier! This illustrates 
a couple points I make with students: (1) taking more time at the start 
to think of possible solution methods, particularly approaching the 
problem from very different perspectives, can save a lot of work; (2) 
though you may not see the elegant approach, you can often get to the 
answer just as well by a less creative route; and (3), that even the 
best of us can do the latter!

Thanks, again, for pointing this out. Showing different ways to see a 
problem is one of our goals -- one that we often fulfill by accident, 
simply by being different people!

- Doctor Peterson, The Math Forum
Associated Topics:
High School Number Theory
Middle School Number Sense/About Numbers

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994-2015 The Math Forum