text: Color all boxes in line such that every M consecutive boxes are unique | Javascript implementation of the approach ; Function to return ( m ! % MOD ) ; Driver code
code: const MOD = 1000000007 ; function modFact ( n , m ) { let result = 1 ; for ( let i = 1 ; i <= m ; i ++ ) result = ( result * i ) % MOD ; return result ; } let n = 3 , m = 2 ; document . write ( modFact ( n , m ) ) ;