PROBLEM 91
Hard

Product of Four Digits

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#91

Given a positive four-digit integer, print the product of its digits.

EXAMPLE

Example

Input
1234
Output
24

LIMITS

Constraints

1000 ≤ n ≤ 9999
📖
LEARN Theory for this problem
+

### Product of Four Digits

Integer division separates higher decimal/time units, while `%` returns the remainder. These two operations let a program isolate digits or split a total number of seconds/minutes into components.

💡
NEED HELP? Hints
+

['Decide which part comes from division and which part comes from the remainder.', 'After each iteration, it should be clear what has already been accumulated and what remains to be processed.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let n = Number(input);
let a = Math.floor((n) / (1000));
let b = (((Math.floor((n) / (100))) % (10)) + (10)) % (10);
let c = (((Math.floor((n) / (10))) % (10)) + (10)) % (10);
let d = (((n) % (10)) + (10)) % (10);
console.log(((a * b) * (c)) * (d));