Product of Nonzero Digits
EasyMath
Description
Given a non-negative integer n, return the product of its non-zero decimal digits. If n is 0, return 0.
Examples
Input:
n = 234Output:
24Explanation:
2 * 3 * 4 = 24.
Input:
n = 1020Output:
2Explanation:
Skip zeros: 1 * 2 = 2.
Input:
n = 0Output:
0Explanation:
Single digit 0 has no non-zero digits to multiply; the answer is 0.
Constraints
- •
0 ≤ n ≤ 10¹⁰