I'll post up my solution as well for anyone who's interested. I basically just did a combinatorics bash on it. I considered how many times each digit appeared to add them up.
Q2: Suppose the number was \([ab]\). (For visual purposes, I will set \( [ab] = 57\).)
Units digits:
- For each \( k \in \{0, \dots, a\}\), the number \( 1, \dots, 9\) all appeared exactly once, contributing \( \sum_{k=0}^9 k \), \(a\) times. This adds \( a \times \frac{9\times 10}{2} \) to the sum. These \(k\)'s represent all the tens values prior to \( [a0]\).
- Then, for that current tens value, we only add the units from \(0\) up to \(b\), which basically contributes \( \sum_{k=0}^b k = \frac{b(b+1)}{2} \) to the sum.
So in the number 57,
For each \(k \in \{0, \dots, 5\} \) we add \( \frac{9\times 10}{2} \) to the sum. One lot comes from 0 to 9, the next lot from 10 to 19, and so on up to 40 to 49.
Then we just add 0+1+...+7
Tens digits:
- For each of the previous 10s values, i.e. each \( \ell \in \{0, \dots, a-1\} \), the number \(\ell\) gets contributed exactly \(10\) times to the sum. So this gives \( 10\times \sum_{\ell = 0}^{a-1} k = 10\times \frac{(a-1)a}{2} \).
- Then, for the current tens value (i.e. \(a\)), we just add \(a\) to the count the number of times as specified by \(b\). This contributes \( \sum_{k=0}^b a = (b+1)a \) to the sum.
So in the number 57,
For the units, we just add 0 ten times, For \( [1b]\), we add 1 ten times. For \([2b]\), we add 2 ten times and so on until we reach 4.
Then, because we have 50, 51, ..., 57, we need to add 5 eight times.
\[ \text{Answer to Q2: }\boxed{45a + \frac{b(b+1)}{2} + 5(a-1)a + (b+1)a}\]
Slight subtlety: If \(a=0\), i.e. we tried applying this formula on a one digit number, the formula will work but the part where it says \( \ell \in \{ 0, \dots, a-1\} \) will appear nonsensical. Essentially for this case, just interpret that set on the right to be empty, i.e. \( \ell \in \emptyset \). (This is a bit of an abuse of notation but still commonly used in combinatorics to represent an empty sum.)
___________________________________________________________________________
Q3: The idea now follows similarly to the previous one so I won't do a numeric example anymore, but it's important to keep track with all the progress.
Units:
- Starts the exact same way, but now we need to go up to the two-digit number \([ab]\) now. So this adds \( \boxed{[ab] \sum_{k=1}^9 k} \) to the sum.
- Finishes the exact same way in that now we just sum the integers up to \(z\) instead, hence contributing \( \boxed{\sum_{k=0}^z k } \) to the sum.
Hundreds:
- Starts the exact same way for the tens in the previous one. We basically do it for each of the previous hundreds values \( \ell \in \{ 0, \dots, a-1\} \), and the idea is that each of these numbers will appear 100 times instead, giving \( \boxed{\sum_{k=0}^{a-1}k} \)
- Finishes pretty much the exact same way as well now, but because we're working modulo 100 we want to terminate at \( [bz]\) instead. So this contributes \( \boxed{\sum_{k=0}^{[bz]} a} \)
Tens: This is the new one - it sorta combines and mixes the methods used in the other cases.
- For each of the previous hundreds values, i.e. \( \ell \in \{0, \dots, a-1\} \), each of the values 0 to 9 will have appeared ten times. (Ten 0's from 0-9, ten 1's from 10-19 and so on, up till ten 9's from 90-99.) This therefore contributes \( 10 \sum_{\ell=0}^{a-1} \sum_{k=0}^9 k \), but since the outer sum really represents summing over constants, I'll at least write \( \boxed{10 (a-1) \sum_{k=0}^9 k} \).
- Then we can narrow our focus to the current hundreds value \(a\). Once we're here, we repeat what we did for the two digit case. For each tens digit \( k \in \{0, \dots, b-1\} \) the same \(k\) appears 10 times, so we have \( \boxed{10 \sum_{k=0}^{b-1} k} \)
- Lastly, keep adding the current tens value \(b\), as required by the current value of \(z\): \( \boxed{\sum_{k=0}^z b} \).
Again, add and simplify using \( \sum_{k=0}^n k = \frac{n(n+1)}{2} \) to get the answer. Note that this formula can easily be derived as it is the partial sum of an arithmetic progression.