In analytic number theory, Mertens' theorems are three 1874 results related to the density of prime numbers proved by Franz Mertens.
 In the following, let 
  
    
      
        p
        ≤
        n
      
    
    {\displaystyle p\leq n}
  
 mean all primes not exceeding n.
 Mertens' first theorem is that
 does not exceed 2 in absolute value for any 
  
    
      
        n
        ≥
        2
      
    
    {\displaystyle n\geq 2}
  
. (A083343)
 Mertens' second theorem is
 where M is the Meissel–Mertens constant (A077761). More precisely, Mertens proves that the expression under the limit does not in absolute value exceed
 for any 
  
    
      
        n
        ≥
        2
      
    
    {\displaystyle n\geq 2}
  
.
 The main step in the proof of Mertens' second theorem is 
 where the last equality needs 
  
    
      
        
          ∑
          
            
              p
              
                k
              
            
            ≤
            n
          
        
        log
        ⁡
        p
        =
        O
        (
        n
        )
      
    
    {\displaystyle \sum _{p^{k}\leq n}\log p=O(n)}
  
 which follows from 
  
    
      
        
          ∑
          
            p
            ∈
            (
            n
            ,
            2
            n
            ]
          
        
        log
        ⁡
        p
        ≤
        log
        ⁡
        
          
            
              (
            
            
              
                2
                n
              
              n
            
            
              )
            
          
        
        =
        O
        (
        n
        )
      
    
    {\displaystyle \sum _{p\in (n,2n]}\log p\leq \log {2n \choose n}=O(n)}
  
.
 Thus, we have proved that
 Since the sum over prime powers with 
  
    
      
        k
        ≥
        2
      
    
    {\displaystyle k\geq 2}
  
 converges, this implies
 A partial summation yields
 In a paper  on the growth rate of the sum-of-divisors function published in 1983, Guy Robin proved that in Mertens' 2nd theorem the difference
 changes sign infinitely often, and that in Mertens' 3rd theorem the difference
 changes sign infinitely often. Robin's results are analogous to Littlewood's famous theorem that the difference π(x) − li(x) changes sign infinitely often. No analog of the Skewes number (an upper bound on the first natural number x for which π(x) > li(x)) is known in the case of Mertens' 2nd and 3rd theorems.
 Regarding this asymptotic formula Mertens refers in his paper to "two curious formula of Legendre", the first one being Mertens' second theorem's prototype (and the second one being Mertens' third theorem's prototype: see the very first lines of the paper). He recalls that it is contained in Legendre's third edition of his "Théorie des nombres" (1830; it is in fact already mentioned in the second edition, 1808), and also that a more elaborate version was proved by Chebyshev in 1851. Note that, already in 1737, Euler knew the asymptotic behaviour of this sum.
 Mertens diplomatically describes his proof as more precise and rigorous. In reality none of the previous proofs are acceptable by modern standards: Euler's computations involve the infinity (and the hyperbolic logarithm of infinity, and the logarithm of the logarithm of infinity!); Legendre's argument is heuristic; and Chebyshev's proof, although perfectly sound, makes use of the Legendre-Gauss conjecture, which was not proved until 1896 and became better known as the prime number theorem.
 Mertens' proof does not appeal to any unproved hypothesis (in 1874), and only to elementary real analysis. It comes 22 years before the first proof of the prime number theorem which, by contrast, relies on a careful analysis of the behavior of the Riemann zeta function as a function of a complex variable.
Mertens' proof is in that respect remarkable. Indeed, with modern notation it yields
 whereas the prime number theorem (in its simplest form, without error estimate), can be shown to imply 
 In 1909 Edmund Landau, by using the best version of the prime number theorem then at his disposition, proved that 
 holds; in particular the error term is smaller than 
  
    
      
        1
        
          /
        
        (
        log
        ⁡
        x
        
          )
          
            k
          
        
      
    
    {\displaystyle 1/(\log x)^{k}}
  
 for any fixed integer k. A simple summation by parts exploiting the strongest form known of the prime number theorem improves this to
 for some 
  
    
      
        c
        >
        0
      
    
    {\displaystyle c>0}
  
.
 Similarly a partial summation shows that 
  
    
      
        
          ∑
          
            p
            ≤
            x
          
        
        
          
            
              log
              ⁡
              p
            
            p
          
        
        =
        log
        ⁡
        x
        +
        C
        +
        o
        (
        1
        )
      
    
    {\displaystyle \sum _{p\leq x}{\frac {\log p}{p}}=\log x+C+o(1)}
  
 is implied by the PNT.
 Merten's third theorem is
 where γ is the Euler–Mascheroni constant (A001620).
 An estimate of the probability of 
  
    
      
        X
      
    
    {\displaystyle X}
  
 (
  
    
      
        X
        ≫
        n
      
    
    {\displaystyle X\gg n}
  
) having no factor 
  
    
      
        ≤
        n
      
    
    {\displaystyle \leq n}
  
 is given by
 This is closely related to Mertens' third theorem which gives an asymptotic approximation of