Hey guys. I am new to the world of investing and am confused on how to properly value a company. my goal (and tell me if I am incorrect) is to find out the value of a company and if it is undervalued in comparison to the stock price purchase stock in said company. I have been trying to figure out how exactly this should be done and Ive heard so much different info its making my head spin.

so if I take a stock that has a market cap of 1.52 billion and I divide that by the current stock price I get a number of just under $40 million (shares outstanding is 40 million so Im not sure weather to take that into account or not?)