For every 1000 people there will be a Level 10 character, for every 1 million people there will be a Level 20 character, for every 1 billion people there will be a Level 30 character.
Using the same idea for every 1 million dragons of CR 20 there will 1 dragon of CR 40 .
As to HOW many dragons in one world....
Lets say the average adult dragon is CR 14 (in 5e ), that means there is 1 adult dragon per 8-10 thousand humanoids. It also means there is 1 ancient dragon for every 4-5 million humanoids.
Extrapolating that means one epic dragon (lets say averaging CR 30) per billion humanoids.
Does that answer your question buddy?
I mean I should probably change the CR of dragons to effective class level (+25% ) to parallel the humanoid levels. But you get the idea.