[Math] Digital number counting

elementary-number-theorysummation

Consider all $100$ digit strings, i.e. those between $0$ to $10^{100}-1$ inclusive. For each number, take the product of non-zero digits (treat any zeros as ones), and sum across all the numbers. What’s the last digit?

Is there a mathematical way (i.e. not using excel brute-force calculation) to do this?

Best Answer

Let $S(n)$ be the specified sum up to $n$ digits. $S(1)=46$, bearing in mind the convention for the zero product, and $$S(n+1)=S(n)+1S(n)+2S(n)+\dots+9S(n)=46S(n)$$ Thus $S(n)=46^n$ and we need to find the last digit of $46^{100}$. Now if $k$ ends in a $6$, so do all its powers, so the last digit is $6$.