An updated answer.
First, check out the block subsidy calculation: https://github.com/bitcoin/bitcoin/blob/v23.0/src/validation.cpp#L1417
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
// Force block reward to zero when right shift is undefined.
if (halvings >= 64)
return 0;
CAmount nSubsidy = 50 * COIN;
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
nSubsidy >>= halvings;
return nSubsidy;
}
An important constant: consensus.nSubsidyHalvingInterval = 210000
comes from this file here:
https://github.com/bitcoin/bitcoin/blob/v23.0/src/chainparams.cpp#L67
Right now the current block height is 704673 (you can look it up here if you like: https://blockexplorer.one/bitcoin/mainnet)
halvings = int(704673 / 210000) == 3
So the current reward 50 >> 3 == 6.25
The sum of a series that halves like that is a/(1-r)
, where a is the first value (50) and r is the ratio (0.5). See: https://en.wikipedia.org/wiki/Geometric_series for more info.
Thus 50 + 25 + 12.5 + 6.25 + 3.125 + 1.5625 + … + 0.000000001 = 100
Since the same amount is given per block, you need only multiply that by the total number of blocks issued per halving: 210000
210,000 * 100 == 21,000,000
Bitcoin is an open source consensus protocol. It's not a company, there is no "foundation", and the code can be reviewed by anyone with about a high school level of knowledge of math.