The answer is 32. There will be 32 halvings, which in theory means 128 years, but in reality it won't quite take that long. Halvings occur automatically, once every 210,000 blocks, not once every 4 years. This latest halving to halving cycle lasted 3 years and 11 months.
The final 21 millionth Bitcoin will have been fully created sometime after the 32nd halving, but long before then, block rewards will have been whittled down to just a few sats.
Halvings won't divide the block reward to zero. Halvings just cut the block reward in half. Block rewards will continue to be earned until the sats from a block reward cause the total supply of all Bitcoin that's ever been created to reach 21,000,000 BTC. That won't happen until after the 32nd halving.
In The Beginning...
Bitcoin was launched in January 2009 with a total of 50 BTC. The first block on the blockchain is known as the Genesis block.
Since then, every 10 minutes (roughly), another 50 BTC was created and awarded to whoever creates the next block. This is known as "The Block Reward."
After every 210,000 blocks, the Block Reward gets cut in half. This is known as "The Halving."
As of April 19th, 2024, the block reward is 3.125 BTC. In 2028, it will be cut in half again, down to 1.5625 BTC. In 2032, it will be cut in half, to 0.78125 BTC.
The Supply As A Whole:
The total supply of Bitcoin is capped at 21 million BTC. That is all which will ever exist. Bitcoin began in 2009 with only 50 BTC total, before block rewards began adding adding another 50 BTC every 10 minutes, cut in half roughly every four years.
2009-2012: 50% of all Bitcoin was created.
2012-2016: Another 25% of all Bitcoin was created.
2016-2020: Another 12.5% of all Bitcoin was created.
2020-2024: Another 6.25% of all Bitcoin was created.
2024-2028: Another 3.125% of all Bitcoin will be created.
2028-2032: Another 1.5625% of all Bitcoin will be created.
2032-2036: Another 0.78125% of all Bitcoin will be created.
2036-2040: Another 0.390625% of all Bitcoin will be created.
This will keep going until the final sats have been awarded, meaning that a total of exactly 21 million Bitcoin has been created.
— Posted on April 19th, 2024