Minimum number of mails required to distribute all the questions | Function returns the min no of mails required ; Using the formula derived above ; No of questions ; No of students ; Maximum no of questions a mail can hold ; Calling function
function MinimumMail ( n , k , x ) { let m = ( n - 1 ) + Math . ceil ( ( n - 1 ) * 1.0 / x ) * ( n - 1 ) + Math . ceil ( n * 1.0 / x ) * ( k - n ) ; return m ; } let N = 4 ; let K = 9 ; let X = 2 ; document . write ( MinimumMail ( N , K , X ) + " " ) ;