Company: Accordion Data Science
Difficulty: medium
Smallest Number with Product of Digits N Problem Description Given an integer N , find the smallest positive integer X whose decimal digits multiply to exactly N . If no such X exists, report -1 . For N = 36 , candidates include 49 ( 4 * 9 ), 66 ( 6 * 6 ) and 94 ( 9 * 4 ), and the smallest of them is 49 . Input Format A single integer N . Output Format One line: the smallest positive integer whose digit product is N , or -1 if there is none. Examples Example 1 Input: 36 Output: 49 Example 2 Input: 100 Output: 455 4 * 5 * 5 = 100 . No two-digit number works, because 100 cannot be written as a product of two digits. Example 3 Input: 1 Output: 1 The single digit 1 already has product 1 . Example 4 Input: 0 Output: 10 A digit product of 0 needs a digit 0 , and the smallest positive integer containing one is 10 . Example 5 Input: 13 Output: -1 13 is prime and larger than 9 , so no set of digits can multiply to it. Example 6 Input: 12 Output: 26 2 * 6 = 12 . The other two-digit options are 3