I'm working on learning probability and statistics by reading a few books and writing some code, and while simulating coin flips I noticed something that struck me as slightly counter to one's naive intuition. If you flip a fair coin $n$ times, the ratio of heads to tails converges towards 1 as $n$ increases, exactly as you would expect. But on the other hand, as $n$ increases, it appears that you become less likely to flip the exact same number of heads as tails, thereby getting a ratio of exactly 1.
For example (some output from my program)
For 100 flips, it took 27 experiments until we got an exact match (50 HEADS, 50 TAILS)
For 500 flips, it took 27 experiments until we got an exact match (250 HEADS, 250 TAILS)
For 1000 flips, it took 11 experiments until we got an exact match (500 HEADS, 500 TAILS)
For 5000 flips, it took 31 experiments until we got an exact match (2500 HEADS, 2500 TAILS)
For 10000 flips, it took 38 experiments until we got an exact match (5000 HEADS, 5000 TAILS)
For 20000 flips, it took 69 experiments until we got an exact match (10000 HEADS, 10000 TAILS)
For 80000 flips, it took 5 experiments until we got an exact match (40000 HEADS, 40000 TAILS)
For 100000 flips, it took 86 experiments until we got an exact match (50000 HEADS, 50000 TAILS)
For 200000 flips, it took 96 experiments until we got an exact match (100000 HEADS, 100000 TAILS)
For 500000 flips, it took 637 experiments until we got an exact match (250000 HEADS, 250000 TAILS)
For 1000000 flips, it took 3009 experiments until we got an exact match (500000 HEADS, 500000 TAILS)
My question is this: is there a concept / principle in statistics / probability theory that explains this? If so, what principle / concept is it?
Link to code if anyone is interested in seeing how I generated this.
-- edit --
For what it's worth, here's how I was explaining this to myself earlier. If you flip a fair coin $\mathtt n$ times and count the number of heads, you're basically generating a random number. Likewise if you do the same thing and count the tails, you're also generating a random number. So if you count both, you're really generating two random numbers, and as $\mathtt n$ gets larger, the random numbers are getting larger. And the larger the random numbers you generate, the more chances there are for them to "miss" each other. What makes this interesting is that the two numbers are actually linked in a sense, with their ratio converging towards one as they get bigger, even though each number is random in isolation. Maybe it's just me, but I find that sort of neat.