Number of ways to distribute N Paper Set among M students | Java 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
import java . util . * ; class GFG { static int MOD = 1000000007 ; static int factMod ( int n ) { long fact = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { fact *= ( i % MOD ) ; fact %= MOD ; } return ( int ) fact ; } static int countWays ( int n , int m ) { return factMod ( m ) ; } public static void main ( String args [ ] ) { int n = 2 , m = 2 ; System . out . print ( countWays ( n , m ) ) ; } }