  Showing: Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Fact Digit Sum
Easy Accuracy: 17.38% Submissions: 144 Points: 2

A(X) for positive integer X is the sum of factorials of its digits. For example, A(154) = 1! + 5! + 4!= 145.
Given a number N, find the minimum number X such that A(X) = N.

Example 1:

Input: N = 40321
Output: 18
Explanation: A(18)=1!+ 8! =40321
Note that A(80) = A(81) is also
40321, But 18 is the smallest
number.


Example 2:

Input: N = 5040
Output: 7
Explanation: A(7) = 7! = 5040.


You don't need to read or print anything. Your task is to complete the function FactDigit() which takes N as input parameter and returns a list of digits which represent the number X.

Expected Time Complexity: O(K) where K ≤ 106
Expected Space Complexity: O(K)

Constraints:
1 ≤ N ≤ 109

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  