Compute n ! under modulo p | Returns value of n ! % p ; Driver Code
function modFact ( n , p ) { if ( n >= p ) return 0 ; let result = 1 ; for ( let i = 1 ; i <= n ; i ++ ) result = ( result * i ) % p ; return result ; } let n = 25 , p = 29 ; document . write ( modFact ( n , p ) ) ;