Modulo 10 ^ 9 + 7 ( 1000000007 ) |  ; f = ( f * i ) % M Now f never can exceed 10 ^ 9 + 7
def factorial ( n ) : NEW_LINE INDENT M = 1000000007 NEW_LINE f = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE return f NEW_LINE DEDENT