Compute n ! under modulo p | Returns value of n ! % p ; Driver Code
def modFact ( n , p ) : NEW_LINE INDENT if n >= p : NEW_LINE INDENT return 0 NEW_LINE DEDENT result = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT result = ( result * i ) % p NEW_LINE DEDENT return result NEW_LINE DEDENT n = 25 ; p = 29 NEW_LINE print ( modFact ( n , p ) ) NEW_LINE