Title: #625 - Minimum Factorization - LeetCode JavaScript Solutions
Open Graph Title: #625 - Minimum Factorization - LeetCode JavaScript Solutions
X Title: #625 - Minimum Factorization - LeetCode JavaScript Solutions
Description: Given a positive integer num, return the smallest positive integer x whose multiplication of each digit equals num. If there is no answer or...
Open Graph Description: Given a positive integer num, return the smallest positive integer x whose multiplication of each digit equals num. If there is no answer or...
X Description: Given a positive integer num, return the smallest positive integer x whose multiplication of each digit equals num. If there is no answer or...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/minimum-factorization
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/minimum-factorization","name":"#625 - Minimum Factorization - LeetCode JavaScript Solutions","description":"Given a positive integer num, return the smallest positive integer x whose multiplication of each digit equals num. If there is no answer or...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number} num\n * @return {number}\n */\nvar smallestFactorization = function(num) {\n if (num < 2) return num;\n\n const digits = [];\n for (let divisor = 9; divisor > 1; divisor--) {\n while (num % divisor === 0) {\n digits.push(divisor);\n num /= divisor;\n }\n }\n\n if (num > 1) return 0;\n\n let result = 0;\n for (const digit of digits.reverse()) {\n result = result * 10 + digit;\n if (result > 2**31 - 1) return 0;\n }\n\n return result;\n};","keywords":"LeetCode 625, #625 - Minimum Factorization, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/minimum-factorization |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/minimum-factorization/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0625-minimum-factorization.js |
| Math | https://leetcodejavascript.com/tags/math |
| Greedy | https://leetcodejavascript.com/tags/greedy |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow