How did Gauss discover the prime number theorem? Carl Friedrich Gauss conjectured in his early youth that 
$$\lim_{x \rightarrow \infty} \frac{\pi(x)}{x/\log(x)} = 1.$$
Any idea how did he reach such result?
 A: It is not quite accurate to say that Gauss discovered the prime number theorem. He made tables of the quantity 
$$\int_2^x\frac{dt}{\ln t}$$
which are reprinted in Harold Edwards' book Riemann's Zeta Function. According to Edwards citing Gauss's Werke, Vol. II Gauss claims (in an 1849 letter) to have conjectured that the density of primes was $1/\log x$ around 1792 or 1793. 
According to Edwards, Gauss presented no analytic basis for the conjecture but gave empirical data in the form of tables suggesting the relation.   
According to the Wiki entry on the PNT Legendre in 1797 or 1798 conjectured a relation of the form $a/(A\ln a + B)$ which he later sharpened. Chebyshev subsequently showed something akin to the prime number theorem but shy of it:
that if 
$$ \lim_{x\to\infty}\frac{\pi(x)}{\int_2^x\frac{dt}{\ln t}}$$ exists the limit is 1. 
Edwards and one of his sources say that the relation given by Legendre had been around for some time. Since Gauss didn't publish it the original source of the general idea is arguably obscure. 
By the time the prime number theorem was finally proven in 1896 by Hadamard and de la Vallee Poussin (separately) is was much more than a guess and not quite a theorem. 
Gauss deserves credit for the numerical observation and for the unpublished conjecture because his credibility in matters of priority is high (which Edwards and others discuss). Properly speaking we can give him credit for the prime number conjecture.  
