Find N from the value of N ! | Map to precompute and store the factorials of the numbers ; Function to precompute factorial ; Calculating the factorial for each i and storing in a map ; Driver code ; Precomputing the factorials
m = { } ; NEW_LINE def precompute ( ) : NEW_LINE INDENT fact = 1 ; NEW_LINE for i in range ( 1 , 19 ) : NEW_LINE INDENT fact = fact * i ; NEW_LINE m [ fact ] = i ; NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT precompute ( ) ; NEW_LINE K = 120 ; NEW_LINE print ( m [ K ] ) ; NEW_LINE K = 6 ; NEW_LINE print ( m [ K ] ) ; NEW_LINE DEDENT