A mechanic's diagnostic tool reads the integer currently displayed on a vehicle's odometer and reports a single 'digit balance' value: the product of all of the reading's digits minus the sum of those same digits. Given the odometer reading, compute this digit balance.
A single integer n — the odometer reading.
Print a single integer: the product of the digits of n minus the sum of the digits of n.
0 <= n <= 100000Example 1
Input
234
Expected
15
Explanation
Digits are 2, 3, 4. Product = 2*3*4 = 24. Sum = 2+3+4 = 9. Balance = 24 - 9 = 15.
Example 2
Input
4421
Expected
21
Explanation
Digits are 4, 4, 2, 1. Product = 4*4*2*1 = 32. Sum = 4+4+2+1 = 11. Balance = 32 - 11 = 21.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →