Scaling black holes are solutions of supergravity with multiple black hole singularities, which can be adiabatically connected to a single center black hole solution. We develop techniques to determine partition functions for such scaling black holes, if each constituent carries a non-vanishing magnetic charge corresponding to a D4-brane in string theory, or equivalently M5-brane in M-theory. For three constituents, we demonstrate that the partition function is a mock modular form of depth two, and we determine the appropriate non-holomorphic completion using generalized error functions. From the four-dimensional perspective, the modular parameter is the axion-dilaton, and our results show that S-duality leaves this subset of the spectrum invariant. From the five-dimensional perspective, the modular parameter is the complex structure of a torus T 2 , and the scaling black holes are dual to states in the dimensional reduction of the M5-brane worldvolume theory to T 2 . As a case study, we specialize the compactification manifold to a K3 fibration, and explicitly evaluate holomorphic parts of partition functions.October 13, 2021(2.23)this condition is always satisfied since a + b − c > 0 and the lhs does not have real roots in this case. Moreover if (c − a)(c − b) ≥ 0, the condition is saturated for ε ± c = 1 M c 1 ± (c−a)(c−b) ab and violated for ε − c < ε < ε + c . Both roots are non-negative provided (a, b, c) obeys the triangle inequality a + b ≥ c. Noting that ε + c > 1 M c , we see ε ≥ ε + c makes r 31 negative. Thus we must have ε ≤ ε − c . Using two other triangle inequalities, we have 1 We apologize for the multiple use of a, b and c.