If I took all the numbers from one to one billion:
- How many of them contain at least one '1'?
- If I wrote them out in one long line, how many 1 digits would there be?
That program took about 15 minutes to run. :)
Well, I couldnt sleep last night because I knew my answer for part 2 was wrong. I am sticking with my answer to part 1 because computer programs dont lie (if the program is written right that is)
Part 2:
From 0-999, there are 300 "1"s, and from 0-1 Billion, there are one million sets of (0-999) for each of the 3 groupings:
1,(GROUP1),(GROUP2),(GROUP3)
So, my next stab at part 2 is: 3*300*1,000,000 + 1 (for 1 billion) or 900,000,001