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 = 234
Output:24
Explanation:

2 * 3 * 4 = 24.

Input:n = 1020
Output:2
Explanation:

Skip zeros: 1 * 2 = 2.

Input:n = 0
Output:0
Explanation:

Single digit 0 has no non-zero digits to multiply; the answer is 0.

Constraints

  • 0 ≤ n ≤ 10¹⁰

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.