Plot Summer 2026
5 . 1 . 17
Longest Streak
In this program we are going to extend the Coin Flips program from earlier.
Now we will simulate flipping a coin FLIPS times, printing out the result of each flip
(either “Heads” or “Tails”), but at the end we will print out the longest streak of heads.
For example, if we set FLIPS = 10; a run may output the following:
Heads
Heads
Tails
Heads
Tails
Tails
Heads
Heads
Heads
Heads
Longest streak of heads: 4
If we flipped a coin ten (10) times would the longest streak always be four? Over a
hundred trials what would be the longest streak on average?
If we flipped a hundred times instead, over a hundred trials, what would be the longest
streak on average?
If we flipped two hundred times? Three hundred? A thousand, over a hundred trials?
Calculate the average longest streak over a hundred trials for each number of flips.
Number of flips 100 200 300 400 500 600 700 800 900 1000
Average longest streak 6.0 6.89 7.7 7.88 8.29 8.5 8.81 9.05 9.25 9.34
Plot the results.
<plot>
END