Quantcast XP Math - Forums - View Single Post - Intermediate How Many Ones?
Thread: Intermediate How Many Ones?
View Single Post
Old 04-20-2009   #5
MAS1

 
Join Date: Dec 2008
Posts: 249
Default

Quote:
Originally Posted by Sugengz View Post
Using Mathematica the answer is 600,000...

Here is the code:

For[x = 1; y = 0, x <= 999999, x++; y = y + StringCount[ToString[x], "1"]]; Print[y]
Yes.
There are 1,000,000 numbers between 0 and 999,999.
We can think of each of these numbers as having six digits whether 000,001 or 999,973.
So if there are 1 million numbers with six digits each then there are six million total digits.
Since we are going from 000,000 to 999,999 and there are ten digits (0,1,2,ā€¦,8,9), then each digit is used the same number of times.
So there must be 6,000,000 / 10 = 600,000 of each digit used
Therefore, there are 600,000 ā€œ1sā€ between 0 and 999,999.

Also, there are:
1 "1" between 0 and 9
20 "1's" between 0 and 99
300 "1's" between 0 and 999
4,000 "1's" between 0 and 9,999
50,000 "1's" between 0 and 99,999
600,000 "1's" between 0 and 999,999
etc
MAS1 is offline   Reply With Quote