Number of ways to distribute N Paper Set among M students | javascript implementation of the approach ; Function to return n ! % 1000000007 ; To store the factorial ; Find the factorial ; Function to return the count of possible ways ; Driver code
MOD = 1000000007 ; function factMod ( n ) { var fact = 1 ; for ( i = 2 ; i <= n ; i ++ ) { fact *= ( i % MOD ) ; fact %= MOD ; } return parseInt ( fact ) ; } function countWays ( n , m ) { return factMod ( m ) ; } var n = 2 , m = 2 ; document . write ( countWays ( n , m ) ) ;