← Back to challenges

Maximum Product of Digits

JavaScriptHardnumbersmath

Instructions

Write a function that returns all numbers less than or equal to N with the maximum product of digits.

Examples

maxProduct(8) ➞ [8]

maxProduct(27) ➞ [27]

maxProduct(211) ➞ [99, 199]

maxProduct(9578) ➞ [8999]

Notes

Search for numbers in the range: [0, n].

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.