PROBLEM STATEMENT
You are given an int N. Find the smallest positive integer X such that the product of its digits
(in decimal notation) is equal to N. Return the number of digits in X, or return -1 if such a
number does not exist.
DEFINITION
Class:ProductOfDigits
Method:smallestNumber
Parameters:int
Returns:int
Method signature:int smallestNumber(int N)
CONSTRAINTS
-N will be between 1 and 1,000,000,000, inclusive.
EXAMPLES
0)
1
Returns: 1
Just take X = 1. It contains 1 digit.
1)
10
Returns: 2
Here the smallest possible X is 25.
2)
26
Returns: -1
3)
100
Returns: 3
The number 455 has 3 digits and the product of its digits is 4 * 5 * 5 = 100.
4)
2520
Returns: 4
5)
864
Returns: 4
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.