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
< ? php function MinimumMail ( $ n , $ k , $ x ) { $ m = ( $ n - 1 ) + ceil ( ( $ n - 1 ) * 1.0 / $ x ) * ( $ n - 1 ) + ceil ( $ n * 1.0 / $ x ) * ( $ k - $ n ) ; return $ m ; } $ N = 4 ; $ K = 9 ; $ X = 2 ; echo MinimumMail ( $ N , $ K , $ X ) , " STRNEWLINE " ; ? >