Let p(n) denote the product of the nonzero digits of n. For example, p(5) = 5, p(37) = 21, and p(604) = 24. Without resorting to a computer, evaluate
p(1) + p(2) + p(3) + ... + p(999999).
Consider the 1-digit, 2-digit, etc. numbers separately.
The values for the 1-digit numbers total 45.
That 45 is, of course, 1+2+3+4+5+6+7+8+9. But these are also the possibilities for the second digit of 2-digit numbers. Each is combined with each of the 1-digit numbers, and due to the associative property, when you multiply each 2-digit numbers' digits and add them, you'll get (1+2+3+4+5+6+7+8+9)*(1+2+3+4+5+6+7+8+9) or 45^2.
Similarly for each number of digits, the new digit is appended to the end of the previous digits, giving 45^n as the total within number of digits.
We need to sum the first six powers of 45. It's like taking a repunit in base 45, seven long, and subtracting 1 (the 45^0 position).
The sum of powers zero through six of 45 is (45^7-1)/44 = 8,492,487,571; subtracting 1 makes it 8,492,487,570, the answer.
|
Posted by Charlie
on 2019-08-23 10:54:18 |