- What is the sum of the digits of all numbers from 1 to 1000000?
- In general, what is the sum of all digits between 1 and N?
- f(n) is a function counting all the ones that show up in 1, 2, 3, ..., n. so f(1)=1, f(10)=2, f(11)=4 etc. When is the first time f(n)=n.
So for the first question, I tried thinking about it such that between 000000 and 999999, each digit will appear the same number of times, so if I find out how many times one digit appears I can just apply that to the other 9 digits (then add 1 for the last number 1000000):
(the number of times 1 digit appears)*(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) = ...
1 Appears once between 1 and 9 1 appears 11 times between 1 and 99 1 appears 11 * 10 + 10 = 120 times between 1 and 999 ...I'm not sure how to find the pattern
But firstly I'm not so sure of my approach, secondly I'm not sure about how to find how many times one particular number appears, and third if this method worked it doesn't seem very good for solving the second part of the question.
Lastly, I had a similar question to the first 2 (question 3) so I just grouped it with those. I hope they are related, and if not I can make a seperate question for that one.
Thanks.