I don't see any obvious numerical relationship - exponential or otherwise - between those font sizes. The intervals in your example are 7, 18, 10, 4, and 4. That's neither linear nor exponential, nor even a curve; it's entirely arbitrary.
There has to be some mathematical relationship between the desired font sizes before you can write something to calculate it automatically.