Maximizing Probability of one type from N containers | Returns the Maximum probability for Drawing 1 copy of number A from N containers with N copies each of numbers A and B ; Pmax = N / ( N + 1 ) ; Driver Code ; 1. N = 1 ; 2. N = 2 ; 3. N = 10
function calculateProbability ( N ) { let probability = N / ( N + 1 ) ; return probability ; } let N ; let probabilityMax ; N = 1 ; probabilityMax = calculateProbability ( N ) ; document . write ( " " + " " + N + " " + Math . round ( probabilityMax * 10000.0 ) / 10000.0 + " " ) ; N = 2 ; probabilityMax = calculateProbability ( N ) ; document . write ( " " + N + " " + Math . round ( probabilityMax * 10000.0 ) / 10000.0 + " " ) ; N = 10 ; probabilityMax = calculateProbability ( N ) ; document . write ( " " + N + " " + Math . round ( probabilityMax * 10000.0 ) / 10000.0 + " " ) ;