Question about a lesser-known "class number formula" of Gauss

Concerning the historic significance of Gauss's article 301: Marius Overholt traces back to this publication on the growth of class numbers the use of local averaging to study the growth of arithmetic functions.


I think the only detailed discussion of this particular result of Gauss is due to Dirichlet, and appears in his 1838 publication "on the use of infinite series in the theory of numbers", which is available on internet archive on p.376-391 of G. Lejeune Dirichlet's Werke. In fact, this publication of Dirichlet is discussed in a recent (2018) biography of Dirichlet (by Uta C. Merzbach), which cites the pages in Dirichlet's publication on Gauss's formula from D.A article 301:

Finally, Dirichlet observed that by the same kind of analysis he could find the formulas presented in article 301 of Gauss's beautiful work:

Suppose, for example, that it's a question of obtaining the mean number of genera for the determinant $-n$, a number which we shall denote by $F(n)$. If one compares art. 231 (of the D.A) where all the complete characters assignable a priori are enumerated, with art. 261 and 287, where the illustrius author showed that only half of these characters correspond to really existing genera, one could easily find (...) five equations (...) which (on appropriate summing and substituting), result in the asymptotic formula of the mean value of the number of genera for a determinant $-n$ as $$\frac{4}{\pi^2}(\mathbb{log (n)}+\frac{12C'}{\pi^2}+2C-\frac{1}{6}\mathbb{log (2)})$$ which coincides with the result of M. Gauss.

Looking at Dirichlet's relatively long reconstruction of Gauss's result, i gained the impression that this is one of those results where truly rigorous analytic methods were needed in it's derivation (this is also evident from the title of Dirichlet's memoir). I think this makes clear that, despite not giving a proof for this result (not even in his Nachlass), Gauss was fully aware of some equivalent form of Dirichlet's L-series technique; Gauss's formula is too precise, and therefore it cannot be assumed that he conjectured it on empirical basis. This might seem to contradict Gauss's own statement from art. 301, according to which he discovered this result after a long tables study - but i guess the "tables study" needs to be interpreted as a "semi-empirical derivation".