Problem 166813 · easy · Level 01 Prerequisites & Setup

Product of the Digits

loops · digits · accumulation

Write digit_product(n) that multiplies all the digits of the non-negative integer n together and returns the result. For n = 0 the answer is 0.

Examples

Input:  n = 234
Output: 24
Explanation: 2 * 3 * 4 = 24

Input:  n = 105
Output: 0

Constraints

  • 0 <= n <= 10**18

Goals

  • Accumulate with multiplication instead of addition
  • Pick a sensible starting value for a product
Starting Python…