Interview Question

Quantitative Developer Interview

-Atlanta, GA

Bank of America

How many numbers between 1 and 1000 contain a 3?

Answer

Interview Answers

13 Answers

4

I would go with elimination of one character from a base 10 numbering system gives you a base 9 numbering system. 9^3 = 729 permutations of a base 9 numbering system (a system with no number 3) with 3 digits, since 10^3 = 1000; 10^3 - 9^3 = 271 thus 271 numbers have a 3 in them.

DareN on

4

There are only 19 numbers between 1 and 100 containing '3': 3, 13, 23, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 53, 63, 73, 83, 93. The same logic holds for 101-200, 301-400, 401-500, 501-600, 601-700, 701-800, 801-900, and 901-1000. That is 19 * 8 = 152. There are 20 numbers between 201-300 that contain a 3: 203, 213, 223, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 243, 253, 263, 273, 283, 293, 300. That brings the sum up to 152 + 20 = 172. Finally, 99 numbers from 301-400 contain a 3. The final sum is 172+99=271. Of course, there are much more intelligent ways to count. For example, instead of counting how many numbers contain a 3, count how many do NOT contain a 3. That means that there are 9 possibilities for the 1st number (0-9 except 3), 9 possibilities for the 2nd number, and 9 possibilities for the 3rd number. Thus, there are 9 * 9 * 9 = 729 that do not contain a 3 which means that there are 1000 - 729 = 271 numbers that do contain a 3.

Interview Candidate on

2

Thanks Candidate, or more simply For 300 to 399 = 100 numbers For other x00 to x99 = 19 numbers each = 19 x 9 = 171 numbers Total of 271 numbers

A Learner on

0

http://brainteaserbible.com/interview-brainteaser-numbers-between-0-and-1000-at-least-one-5 basically the same thing

JDizz on

1

1000 does not contain a 3. So, count the number of 3 digit numbers without a three. There are 9 choices for the first entry, 9 for the second, and 9 for the third. So, there are 729 numbers without a 3, and 1000-729 = 271 with a 3.

KP on

0

I have a much simpler and faster method: let A be the cardinality of numbers between 1 and 1000 that contain a 3 and let A' be the cardinality of numbers between 1 and 1000 that do not contain a 3. There are 3 digits that can take the form of (0,1,2,3,4,5,6,7,8,9), so 10 possibilities.. To obtain A' cardinality we have 9 possibilities because 3 is excluded so A' = 9^3 = 729. Hence, the amount of numbers that don't have a 3 from 1 to 1000 is 729 so to obtain the amount that does contain at least one 3 is : 1000 - 729 = 271

Alex R on

0

lol im in 7th grade and this question is easy to me. first you count the numbers which DON't have a three. there are 9 choices for the first digit, 9 for the second digit, and 9 for the third. You probably noticed that this counts 0 to 999 instead of 1 to 1000 but its okay because, we count the same amount of numbers. 9^3=729 -1000=|271| (i like using absolute value cause it makes me look cool, its just a way to show "difference" in math)

ethan on

0

3xx 100 a3x a is not 3 here to reduce duplication, 10*9 ab3 a , b are neither not 3 , 9*9 =271

Henry on

0

You can use this formula to work it out for any power of 10: Tn+1=9Tn+10^n. Tn being the number of threes in the numbers between 1 and the previous power of 10. Tn+1 is simply saying the number of threes in the next power (the one you are working out). The 10^n is the power of 10 that you add on. This is the previous power of ten. You must start off knowing that there is one 3 between 1 and 10 For 100: Tn+1=9*1+10^1=19 For 1000: Tn+1=9*19+10^2=271 For 10 000: Tn+1=9*271+10^3=3439

Anonymous on

0

1000-1-9^3+1 = 271

StanLXR on

0

It is an infinite number 3.1, 3.11, 3.111, 3.11111

Anonymous on

6

300 numbers contain a 3, but you counted numbers of the form x33, 3x3, and 33x *twice* so you must subtract them 300-30=270, but you subtracted 333 once too many, so add it back 300-30+1=271. Answer is 271.

Anonymous on

0

271 does not seem right . I think it is 111. Aren't there just 11 numbers containing 3 between 0 an 100, like 3,13,23 30,33 etc. So between 0 and 1000 there are 111; after adding in for 300.

Bob on

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

Add Answers or Comments

To comment on this, Sign In or Sign Up.