Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save qodirovshohijahon/3cedc681351086d7141a0cb84d9fc6bd to your computer and use it in GitHub Desktop.
Save qodirovshohijahon/3cedc681351086d7141a0cb84d9fc6bd to your computer and use it in GitHub Desktop.
**
* @param {number} n
* @return {number}
*/
var subtractProductAndSum = function(n) {
let strNum = n.toString();
let arr = strNum.split("");
let mul = 1, count = 0;
for (let i = 0; i < arr.length; i++) {
mul *= arr[i];
}
for (let j = 0; j < arr.length; j++) {
count += parseInt(arr[j]);
}
return mul - count;
};
@qodirovshohijahon
Copy link
Author

Subtract the Product and Sum of Digits of an Integer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment