3. (1 mark) Find the sum of all integers from 1 to 1000 which contain at least one " 7 " in their digits.
(1 分) 求由 1 至 1000 內所有包含 “ 7 ”這數字的整數的總和。
3. The sum of the numbers from 700 to 799 is $\frac{1}{2} \times 799 \times 800-\frac{1}{2} \times 699 \times 700=74950$. The sum of the numbers from 70 to 79 is $\frac{1}{2} \times 79 \times 80-\frac{1}{2} \times 69 \times 70=745$. Hence all numbers that end from 70 to 79 (excluding those starting from 7 , as we have already counted those from 700 to 799 ) is $745 \times 9+10(100+200+\cdots+600+800+900)=44705$. The sum of all numbers ending in 7, (excluding the previous two cases), is $9(7+17+\cdots+67+87+97)+9(100+200+\cdots+600+800+900)=38187$. So the total sum of numbers containing a " 7 " is $74950+47705+38187=\underline{\underline{157842}}$.

Alternate Solution

Let $\mathrm{P}$ and $\mathrm{Q}$ be respectively the sum of all positive integers less than 1000 and the sum of all positive integers containing no " 7 "s in their digits. Clearly $P=\frac{999 \times 1000}{2}=499500$. On the other hand, we can easily see $Q$ is the sum of $9^{3}=729$ numbers. Considering the unit digits of these numbers, there should be $81\left(=\frac{729}{9}\right)$ occurrences for each digit except 7 . Therefore, the sum of all unit digits equals $81 \times(0+1+2+\ldots . .+6+8+9)=81 \times 83$. The same is true for the tenth and hundredth digits. Hence, $Q=81 \times 83 \times(1+10+100)=341658$. Finally, the answer required is therefore $P-Q=\underline{\underline{157842}}$