30:00
Given an integer n, return the product of its digits minus the sum of its digits.
1≤n≤1051 \leq n \leq 10^51≤n≤105
Run code to see results.
Start product at 1 and total at 0, the values that leave a first digit unchanged when you multiply or add it.
n = 234, digits peeled from the right
10^2
10^1
10^0
two running totals
product
1
= 1
sum
0
= 0
answer
Multiply the digits of n together, add them together, and return the product minus the sum. The whole problem is the standard digit-peeling loop with two accumulators.