QS-012 · Brain Teasers · Medium

Find The Units Digit

Digit Product Sum Pattern

Consider every 100-digit number (including those with leading zeros), i.e. all integers from 0 to $10^{100}-1$. For each such number, compute the product of its nonzero digits (and by convention treat the product for the number zero as 1). Sum these products over all $10^{100}$ numbers. What is the last decimal digit of the sum? **Note:** For the numbers 0 to 9, this sum (of product of non-zero digits) is 46 (and not 45), as the number 0 contributes 1 to the total since, by convention, we treat the product for the zero as 1.
Solution Let $S(n)$ be the sum of the "product of nonzero digits" over all $n$-digit strings, allowing leading zeros. For $n=1$, the ten strings are $0$ through $9$, whose nonzero-digit products are $1,1,2,3,\ldots,9$. Hence $$ S(1)=1+1+2+3+\cdots+9=46. $$ To build an $(n+1)$-digit string, choose its last digit $d$ and an $n$-digit prefix. If $d=0$, the contribution is $S(n)$. If $d=k\in{1,\ldots,9}$, the contribution is $kS(n)$. Thus, $$ S(n+1)=S(n)+\sum_{k=1}^{9}kS(n) =46S(n). $$ Since $S(1)=46$, by induction, $$ S(n)=46^n. $$ Therefore, $$ S(100)=46^{100}. $$ Since 46 ends in 6, every positive power of 46 also ends in 6. Hence the required last decimal digit is $$ \boxed{6}. $$

Open interactive problem view

Browse more quantitative interview problems