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 ) ; 1. N = 1 ; 2. N = 2 ; 3. N = 10
def calculateProbability ( N ) : NEW_LINE INDENT probability = N / ( N + 1 ) NEW_LINE return probability NEW_LINE DEDENT N = 1 NEW_LINE probabilityMax = calculateProbability ( N ) NEW_LINE print ( " Maximum ▁ Probability ▁ for ▁ N ▁ = ▁ " , N , " is , ▁ % .4f " % probabilityMax ) NEW_LINE N = 2 NEW_LINE probabilityMax = calculateProbability ( N ) ; NEW_LINE print ( " Maximum ▁ Probability ▁ for ▁ N ▁ = " , N , " is , ▁ % .4f " % probabilityMax ) NEW_LINE N = 10 NEW_LINE probabilityMax = calculateProbability ( N ) ; NEW_LINE print ( " Maximum ▁ Probability ▁ for ▁ N ▁ = " , N , " is , ▁ % .4f " % probabilityMax ) NEW_LINE