text: Trick for modular division ( ( x1 * x2 ... . xn ) / b ) mod ( m ) | Python3 program to implement the above approach To run this code , we need to copy modular inverse from below post . https : www . geeksforgeeks . org / multiplicative - inverse - under - modulo - m / ; naive method - calculating the result in a single line ; modular_inverse ( ) is a user defined function that calculates inverse of a number ; it will use extended Eucledian algorithm or Fermat 's Little  Theorem for calculation.  MMI of 120 under division by  1000000007 will be 808333339
code: if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT naive_answer = ( ( ( 55555 * 55554 * 55553 * 55552 * 55551 ) // 120 ) % 1000000007 ) NEW_LINE ans = 1 NEW_LINE i = modular_inverse ( 120 , 10000007 ) NEW_LINE for i in range ( 5 ) : NEW_LINE INDENT ans = ( ( ans * ( 55555 - i ) ) % 1000000007 ) NEW_LINE DEDENT ans = ( ans * i ) % 1000000007 NEW_LINE print ( " Answer ▁ using ▁ naive ▁ method : " , naive_answer ) NEW_LINE print ( " Answer ▁ using ▁ multiplicative " + " modular ▁ inverse ▁ concept : " , ans ) NEW_LINE DEDENT