Imagine, as in some of the other answers, a company whose stock sells for $90 and whose earnings this year were $10. The resultant P/E is 9.
As has been stated, if the company pays out all of the $10 as a dividend and continues to do so for the next nine years, then you will recoup your entire $90 investment in nine years.
However, most companies do not pay out their entire earnings in dividends. In addition to dividends, there are two other things companies do with earnings. First is re-investment in the business. They use some of the earnings to hire another salesperson and equip them with a company car, or they buy a new forklift or add a second assembly line.
Theoretically, re-investment increases the value of the company which, again, theoretically, is relected in the stock price. So investors may get a $5 dividend and the stock price may increase $5.
Second, the company may simply retain the earnings; that is, put the money in the bank. Perhaps they haven't yet found a suitable re-investment opportunity and will just hold the earnings until they do.
Again, theoretically, retained earnings increases the value of the company which, again, theoretically, is relected in the stock price. So investors may get a $5 dividend and the stock price may increase $5.
In either case, the company decides whether to declare a dividend or not. They decide whether to give most of the earnings to dividends, perhaps $8 in the example, or little or no dividend at all.
The stock price will not be determined by math and logic, however. It will be determined by thousands of investors who may think that the company has a bright or a dim future, that the re-investment scheme is likely to increase or decrease future earnings, or that the dividend rate, if any, is good or bad. Some of these investors may be entirely correct and some (most?) will be wrong. They, however, are the ones that will ultimately determine the stock price by their willingness to buy or sell at $90 but not $91.
So, does that mean if you invest $100 into the company, and the company is not growing at all, that it will take 9 years to earn back your investment? The answer is, possibly.