I didnt understand the guest's way, so ill solve it my way:
P(k)=the number of times the digit k appears between 0 and 999,999. P(0)*0+P(1)*1+P(2)*2+....+P(9)*9+1= the sum we need to find (i replaced 1,000,000 with 0, all we need to do is add 1 to the final solution.
all the numbers between 0 and 999,999 are also every possible combination of 6 digits (instead of 1 we write 0000001, instead of 2 we write 000002. Yes, a large number of zeroes is added, but that doesnt change the solution because x+n*0=x+0=x)
Here's a link to a similar question someone asked about the number of times a digit appears between 1 and 10n(n is a positive integer):
https://web2.0calc.com/questions/how-many-3s#r21
. i told him that between 0 and 10n-1 ,every digit (if we write it the way i write the numbers) appears n*10n-1 times, meaning every digit except for 0 appears n*10n-1 (but we dont care about the zeroes). what we want to find is the number of times every digit (except for 0) appears between 0 and 999,999=106-1. so, the answer is 6*106-1=6*105.
so, P(k)=6*105 for every k that is between 1 and 9.
P(0)*0+P(1)*1+P(2)*2+....+P(9)*9+1=P(1)*1+P(2)*2+....+P(9)*9+1=6*105(1+2+3+4....+9)+1=6*105*45+1=27,000,000+1=
27,000,001