Digit Product
JavaScript
Easy
4 views
Problem Description
Given an integer n, find the product of its digits (ignore sign). Print the product.
Input Format
One integer n.
Output Format
One integer product.
Official Solution
const fs=require('fs');let s=fs.readFileSync(0,'utf8').trim();if(!s)process.exit(0);if(s[0]==='-')s=s.slice(1);if(s==='')s='0';let prod=1n;for(const ch of s){prod*=BigInt(ch.charCodeAt(0)-48);}process.stdout.write(prod.toString());
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!