Rolls Until Something Repeats
You roll a fair six-sided die over and over and stop on the first roll showing a face you have already seen. Let be the total number of rolls, counting the repeat itself.
p, expected = 1.0, 0.0
for k in range(7): # P(N > k) = 6*5*...*(6-k+1) / 6**k
expected += p
p *= (6 - k) / 6
print(round(expected, 2))
What does this print?
Answer format: round to 2 decimal places.
Sign in to answer questions and track your progress
Sign In