Because of cascading all possible transitions are seen. Thus we look for the number of ways in which we can select upper and lower levels. The number of ways we can do this is
1/2n(n-1)
where the factor 1/2 takes account of the fact that the photon emission always arises from upper →lower transition.