Maximum Product of Digits

Published by Helen Yu in

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].

Watch a quick demo on how Edabit works.