Math question

Rowboat

Senior member
May 25, 2007
200
0
0
I feel like I know this somewhere but can't seem to remember how to get started.

I have a range of numbers 700 to 999 and I need to buy enough 0's 1's 2's .. 9's in order to print each number in that range.

Is there a math formula that will calculate this? or an excel formula?

Thanks, its really bugging me that I can't think of it.
 

chuckywang

Lifer
Jan 12, 2004
20,133
1
0
Originally posted by: Rowboat
I feel like I know this somewhere but can't seem to remember how to get started.

I have a range of numbers 700 to 999 and I need to buy enough 0's 1's 2's .. 9's in order to print each number in that range.

Is there a math formula that will calculate this? or an excel formula?

Thanks, its really bugging me that I can't think of it.

That's 300 numbers, each number has 3 digits, so you need 900 digits altogether.
 

mugs

Lifer
Apr 29, 2003
48,920
46
91
I don't know if there is a formula, but you could break it down in your head pretty easily.

From 700-799 you need 100 7s for the 100s place.
From 700-799 you need 10 of each digit for the 10s place.
From 700-799 you need 10 of each digit for the 1s place.

Repeat for 800-899 and 900-999, so you'd need:

160 7s
160 8s
160 9s
60 of each other digit.
 

Rowboat

Senior member
May 25, 2007
200
0
0
Originally posted by: mugs
I don't know if there is a formula, but you could break it down in your head pretty easily.

From 700-799 you need 100 7s for the 100s place.
From 700-799 you need 10 of each digit for the 10s place.
From 700-799 you need 10 of each digit for the 1s place.

Repeat for 800-899 and 900-999, so you'd need:

160 7s
160 8s
160 9s
60 of each other digit.

Great, that makes perfect sense, sometimes you get caught up in a complex solution when all you need is something simple
 
Nov 5, 2001
18,366
3
0
Originally posted by: Rowboat
Originally posted by: mugs
I don't know if there is a formula, but you could break it down in your head pretty easily.

From 700-799 you need 100 7s for the 100s place.
From 700-799 you need 10 of each digit for the 10s place.
From 700-799 you need 10 of each digit for the 1s place.

Repeat for 800-899 and 900-999, so you'd need:

160 7s
160 8s
160 9s
60 of each other digit.

Great, that makes perfect sense, sometimes you get caught up in a complex solution when all you need is something simple

.
 

OdiN

Banned
Mar 1, 2000
16,430
3
0
Originally posted by: chuckywang
Originally posted by: Rowboat
I feel like I know this somewhere but can't seem to remember how to get started.

I have a range of numbers 700 to 999 and I need to buy enough 0's 1's 2's .. 9's in order to print each number in that range.

Is there a math formula that will calculate this? or an excel formula?

Thanks, its really bugging me that I can't think of it.

That's 300 numbers, each number has 3 digits, so you need 900 digits altogether.

This.

Do the digits "cost" something different for some stupid reason?
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
There's no easy formula for this off the top of my head, but it shouldn't be hard to derive one.

First, for any three-digit decimal number ABC (i.e., 100 * A + 10 * B + C, where A,B,C are 0 through 9) let's find a way to count the number of times a specific digit appears when printing the numbers 1 through ABC.

For instance, let's count the number of "5's" used to print all the decimal numbers 1 through ABC.

Now a "5" can appear in the ones place, the tens place, or the hundreds place-- so let's count each seperately.

We first note that the numbers 1 through 10 contain one number which has a "5" in the ones place (specifically, the number 5 itself). Similarly, the numbers 11 through 20 contain exactly one number which has a "5" in the ones place (namely, the number 15). In fact, each of the following sets of ten consecutive numbers has exactly one number with a "5" in the ones place. There are precicely 10 * A + B such full sets, so there are at least 10 * A + B "5"'s used in the ones place. I say "at least", because the numbers AB0 through ABC may contain an additional number which ends in 5-- in fact, if C is 5, 6, 7, 8, or 9 then it does. Hence, the total number of "5"s that appears in the ones place is 10 * A + B if C < 5, and 10 * A + B + 1 if C >= 5.

Now we count the number of "5"'s that appear in the tens place. We note that each set of numbers 1 - 100, 101-200, etc. each contain exactly 10 numbers which have a "5" in the tens place (for instance, 50-59 and 150-159). There are A such sets, so there are at least 10 * A "5"'s that appear in the tens place. Similiar to above, between the numbers A00 and ABC there may be some additional numbers that have a "5" in the tens place. Specifically, if B > 5, then there are 10 such numbers. If B = 5, then there are C + 1 such numbers. If B < 5, there there are no additional numbers. Hence, the total number of "5"'s that appear in the tens place is 10 * A if B < 5, 10 * A + C + 1 if B = 5, and 10 * A + 10 if B > 5.

Now we count the number of "5"'s that appear the hundreds place. We note that if A > 5, then there are 100 such numbers (namely, 500-599). If A = 5, then there 10 * B + C + 1 such numbers (names, 500 - 5BC). If
A < 5 then there are none. Hence, the total number of "5"'s that appear in the hundreds place is 0 if A < 5, 10 * B + C + 1 if A = 5, and 100 if A > 5.

Therefore, the total number of 5's that appear in the numbers 1 through ABC can be summed as follows:

20 * A + B
+ 1 (if C > 5)
+ 1 (if B = 5)
+ 10 (if B > 5)
+ 10 * B + C + 1 (if A = 5)
+ 100 (if A > 5)

You can generalize this for any decimal digit i (where i = 1, 2, 3, 4, 5, 6, 7, 8 or 9) as follows:

20 * A + B
+ 1 (if C > i)
+ 1 (if B = i)
+ 10 (if B > i)
+ 10 * B + C + 1 (if A = i)
+ 100 (if A > i)

You can use the above "formula" to calculate the number of "5"'s that are used between a range of two 3-digit numbers (say, between 274 and 632) by simply calcuating how many are used from 1 through 632, and then subtracting how many are used from 1 through 274-1=273. The number of "5"'s used from 1 through 632 is 20 * 6 + 3 + 100, or 323. The number of "5"'s used from 1 through 273 is 20 * 2 + 7 + 10, or 57. Hence, there are 323-57=266 "5"'s used between 274 and 632.

 

oznerol

Platinum Member
Apr 29, 2002
2,476
0
76
www.lorenzoisawesome.com
Originally posted by: QED
There's no easy formula for this off the top of my head, but it shouldn't be hard to derive one.

First, for any three-digit decimal number ABC (i.e., 100 * A + 10 * B + C, where A,B,C are 0 through 9) let's find a way to count the number of times a specific digit appears when printing the numbers 1 through ABC.

For instance, let's count the number of "5's" used to print all the decimal numbers 1 through ABC.

Now a "5" can appear in the ones place, the tens place, or the hundreds place-- so let's count each seperately.

We first note that the numbers 1 through 10 contain one number which has a "5" in the ones place (specifically, the number 5 itself). Similarly, the numbers 11 through 20 contain exactly one number which has a "5" in the ones place (namely, the number 15). In fact, each of the following sets of ten consecutive numbers has exactly one number with a "5" in the ones place. There are precicely 10 * A + B such full sets, so there are at least 10 * A + B "5"'s used in the ones place. I say "at least", because the numbers AB0 through ABC may contain an additional number which ends in 5-- in fact, if C is 5, 6, 7, 8, or 9 then it does. Hence, the total number of "5"s that appears in the ones place is 10 * A + B if C < 5, and 10 * A + B + 1 if C >= 5.

Now we count the number of "5"'s that appear in the tens place. We note that each set of numbers 1 - 100, 101-200, etc. each contain exactly 10 numbers which have a "5" in the tens place (for instance, 50-59 and 150-159). There are A such sets, so there are at least 10 * A "5"'s that appear in the tens place. Similiar to above, between the numbers A00 and ABC there may be some additional numbers that have a "5" in the tens place. Specifically, if B > 5, then there are 10 such numbers. If B = 5, then there are C + 1 such numbers. If B < 5, there there are no additional numbers. Hence, the total number of "5"'s that appear in the tens place is 10 * A if B < 5, 10 * A + C + 1 if B = 5, and 10 * A + 10 if B > 5.

Now we count the number of "5"'s that appear the hundreds place. We note that if A > 5, then there are 100 such numbers (namely, 500-599). If A = 5, then there 10 * B + C + 1 such numbers (names, 500 - 5BC). If
A < 5 then there are none. Hence, the total number of "5"'s that appear in the hundreds place is 0 if A < 5, 10 * B + C + 1 if A = 5, and 100 if A > 5.

Therefore, the total number of 5's that appear in the numbers 1 through ABC can be summed as follows:

20 * A + B
+ 1 (if C > 5)
+ 1 (if B = 5)
+ 10 (if B > 5)
+ 10 * B + C + 1 (if A = 5)
+ 100 (if A > 5)

You can generalize this for any decimal digit i (where i = 1, 2, 3, 4, 5, 6, 7, 8 or 9) as follows:

20 * A + B
+ 1 (if C > i)
+ 1 (if B = i)
+ 10 (if B > i)
+ 10 * B + C + 1 (if A = i)
+ 100 (if A > i)

You can use the above "formula" to calculate the number of "5"'s that are used between a range of two 3-digit numbers (say, between 274 and 632) by simply calcuating how many are used from 1 through 632, and then subtracting how many are used from 1 through 274-1=273. The number of "5"'s used from 1 through 632 is 20 * 6 + 3 + 100, or 323. The number of "5"'s used from 1 through 273 is 20 * 2 + 7 + 10, or 57. Hence, there are 323-57=266 "5"'s used between 274 and 632.

I nominate this post for the most overly complex solution to an already answered problem.
 

Rowboat

Senior member
May 25, 2007
200
0
0
Originally posted by: ducci
Originally posted by: QED
...

I nominate this post for the most overly complex solution to an already answered problem.

Heh, i did ask for a formula.

Basically we need to build a punch set for each of those number combinations and needed to know how many of each number to buy. I confirmed the above solution 160 for 7,8,9 and 60 for the rest with a spreadsheet formula I found. FYI

A1:A300 = 700-999
text to columns to break it out into A1 A2 A3 7 0 0 etc

array formula (shift ctrl enter)

{=SUM(IF($A$1:$C$300=0,1,0))}
{=SUM(IF($A$1:$C$300=1,1,0))}
{=SUM(IF($A$1:$C$300=2,1,0))}

etc for all 10 digits

and excel summed it up nicely. The more you know.
 
Oct 20, 2005
10,978
44
91
Originally posted by: QED
There's no easy formula for this off the top of my head, but it shouldn't be hard to derive one.

First, for any three-digit decimal number ABC (i.e., 100 * A + 10 * B + C, where A,B,C are 0 through 9) let's find a way to count the number of times a specific digit appears when printing the numbers 1 through ABC.

For instance, let's count the number of "5's" used to print all the decimal numbers 1 through ABC.

Now a "5" can appear in the ones place, the tens place, or the hundreds place-- so let's count each seperately.

We first note that the numbers 1 through 10 contain one number which has a "5" in the ones place (specifically, the number 5 itself). Similarly, the numbers 11 through 20 contain exactly one number which has a "5" in the ones place (namely, the number 15). In fact, each of the following sets of ten consecutive numbers has exactly one number with a "5" in the ones place. There are precicely 10 * A + B such full sets, so there are at least 10 * A + B "5"'s used in the ones place. I say "at least", because the numbers AB0 through ABC may contain an additional number which ends in 5-- in fact, if C is 5, 6, 7, 8, or 9 then it does. Hence, the total number of "5"s that appears in the ones place is 10 * A + B if C < 5, and 10 * A + B + 1 if C >= 5.

Now we count the number of "5"'s that appear in the tens place. We note that each set of numbers 1 - 100, 101-200, etc. each contain exactly 10 numbers which have a "5" in the tens place (for instance, 50-59 and 150-159). There are A such sets, so there are at least 10 * A "5"'s that appear in the tens place. Similiar to above, between the numbers A00 and ABC there may be some additional numbers that have a "5" in the tens place. Specifically, if B > 5, then there are 10 such numbers. If B = 5, then there are C + 1 such numbers. If B < 5, there there are no additional numbers. Hence, the total number of "5"'s that appear in the tens place is 10 * A if B < 5, 10 * A + C + 1 if B = 5, and 10 * A + 10 if B > 5.

Now we count the number of "5"'s that appear the hundreds place. We note that if A > 5, then there are 100 such numbers (namely, 500-599). If A = 5, then there 10 * B + C + 1 such numbers (names, 500 - 5BC). If
A < 5 then there are none. Hence, the total number of "5"'s that appear in the hundreds place is 0 if A < 5, 10 * B + C + 1 if A = 5, and 100 if A > 5.

Therefore, the total number of 5's that appear in the numbers 1 through ABC can be summed as follows:

20 * A + B
+ 1 (if C > 5)
+ 1 (if B = 5)
+ 10 (if B > 5)
+ 10 * B + C + 1 (if A = 5)
+ 100 (if A > 5)

You can generalize this for any decimal digit i (where i = 1, 2, 3, 4, 5, 6, 7, 8 or 9) as follows:

20 * A + B
+ 1 (if C > i)
+ 1 (if B = i)
+ 10 (if B > i)
+ 10 * B + C + 1 (if A = i)
+ 100 (if A > i)

You can use the above "formula" to calculate the number of "5"'s that are used between a range of two 3-digit numbers (say, between 274 and 632) by simply calcuating how many are used from 1 through 632, and then subtracting how many are used from 1 through 274-1=273. The number of "5"'s used from 1 through 632 is 20 * 6 + 3 + 100, or 323. The number of "5"'s used from 1 through 273 is 20 * 2 + 7 + 10, or 57. Hence, there are 323-57=266 "5"'s used between 274 and 632.

LOL, ok there are times when deriving formulas and such are necessary and useful, but c'mon, .....OP's question was answered already w/ something much less complex, do you really need to go through all that?
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
Originally posted by: Schfifty Five

LOL, ok there are times when deriving formulas and such are necessary and useful, but c'mon, .....OP's question was answered already w/ something much less complex, do you really need to go through all that?

I would tend to agree with you... but the thread didn't have a single reply when I started typing out that long response.

:(
 

RapidSnail

Diamond Member
Apr 28, 2006
4,257
0
0
Originally posted by: QED
There's no easy formula for this off the top of my head, but it shouldn't be hard to derive one.

First, for any three-digit decimal number ABC (i.e., 100 * A + 10 * B + C, where A,B,C are 0 through 9) let's find a way to count the number of times a specific digit appears when printing the numbers 1 through ABC.

For instance, let's count the number of "5's" used to print all the decimal numbers 1 through ABC.

Now a "5" can appear in the ones place, the tens place, or the hundreds place-- so let's count each seperately.

We first note that the numbers 1 through 10 contain one number which has a "5" in the ones place (specifically, the number 5 itself). Similarly, the numbers 11 through 20 contain exactly one number which has a "5" in the ones place (namely, the number 15). In fact, each of the following sets of ten consecutive numbers has exactly one number with a "5" in the ones place. There are precicely 10 * A + B such full sets, so there are at least 10 * A + B "5"'s used in the ones place. I say "at least", because the numbers AB0 through ABC may contain an additional number which ends in 5-- in fact, if C is 5, 6, 7, 8, or 9 then it does. Hence, the total number of "5"s that appears in the ones place is 10 * A + B if C < 5, and 10 * A + B + 1 if C >= 5.

Now we count the number of "5"'s that appear in the tens place. We note that each set of numbers 1 - 100, 101-200, etc. each contain exactly 10 numbers which have a "5" in the tens place (for instance, 50-59 and 150-159). There are A such sets, so there are at least 10 * A "5"'s that appear in the tens place. Similiar to above, between the numbers A00 and ABC there may be some additional numbers that have a "5" in the tens place. Specifically, if B > 5, then there are 10 such numbers. If B = 5, then there are C + 1 such numbers. If B < 5, there there are no additional numbers. Hence, the total number of "5"'s that appear in the tens place is 10 * A if B < 5, 10 * A + C + 1 if B = 5, and 10 * A + 10 if B > 5.

Now we count the number of "5"'s that appear the hundreds place. We note that if A > 5, then there are 100 such numbers (namely, 500-599). If A = 5, then there 10 * B + C + 1 such numbers (names, 500 - 5BC). If
A < 5 then there are none. Hence, the total number of "5"'s that appear in the hundreds place is 0 if A < 5, 10 * B + C + 1 if A = 5, and 100 if A > 5.

Therefore, the total number of 5's that appear in the numbers 1 through ABC can be summed as follows:

20 * A + B
+ 1 (if C > 5)
+ 1 (if B = 5)
+ 10 (if B > 5)
+ 10 * B + C + 1 (if A = 5)
+ 100 (if A > 5)

You can generalize this for any decimal digit i (where i = 1, 2, 3, 4, 5, 6, 7, 8 or 9) as follows:

20 * A + B
+ 1 (if C > i)
+ 1 (if B = i)
+ 10 (if B > i)
+ 10 * B + C + 1 (if A = i)
+ 100 (if A > i)

You can use the above "formula" to calculate the number of "5"'s that are used between a range of two 3-digit numbers (say, between 274 and 632) by simply calcuating how many are used from 1 through 632, and then subtracting how many are used from 1 through 274-1=273. The number of "5"'s used from 1 through 632 is 20 * 6 + 3 + 100, or 323. The number of "5"'s used from 1 through 273 is 20 * 2 + 7 + 10, or 57. Hence, there are 323-57=266 "5"'s used between 274 and 632.

You killed Occam's razor. It was a nice razor too. :(
 
Oct 20, 2005
10,978
44
91
Originally posted by: QED
Originally posted by: Schfifty Five

LOL, ok there are times when deriving formulas and such are necessary and useful, but c'mon, .....OP's question was answered already w/ something much less complex, do you really need to go through all that?

I would tend to agree with you... but the thread didn't have a single reply when I started typing out that long response.

:(

LOL....well that sucks haha.
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,601
167
111
www.slatebrookfarm.com
Wow, QED, that was a pretty complicated formula for a much simpler solution, simpler than mugs' solution:
since the 1's and 10's digits go from 00 to 99, each digit appears an equal number of times.
There are a total of 600 such digits. 600 divided by 10 different digits = 60 each.
Then toss in 100 7's, 8's and 9's
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
Originally posted by: DrPizza
Wow, QED, that was a pretty complicated formula for a much simpler solution, simpler than mugs' solution:
since the 1's and 10's digits go from 00 to 99, each digit appears an equal number of times.
There are a total of 600 such digits. 600 divided by 10 different digits = 60 each.
Then toss in 100 7's, 8's and 9's


Yep, your way is quite simple. I read the OP's post a bit too quickly and thought he wanted/needed a general formula, so I went for that instead.

There is a very nice and very "clean" looking formula for the general solution, but I wanted to explain "how" instead of just dropping a formula down.