Function to calculate factorial of all numbers
def StoreFactorials ( n ) : NEW_LINE INDENT factorial [ 0 ] = 1 NEW_LINE for i in range ( 1 , n + 1 , 1 ) : NEW_LINE INDENT factorial [ i ] = ( i * factorial [ i - 1 ] ) % mod NEW_LINE DEDENT DEDENT