1 Introduction

The jth divisor function \(d_j\), which counts the ordered factorisations of a positive integer into j positive integer factors, is a very well-known arithmetic function. In particular, \(d_2(n)\)—sometimes called the divisor function—counts the number of ordered pairs of positive integers whose product is n, and therefore, considering only the first factor in each pair, also counts the number of divisors of n (see papers 8 and 15 of [11] and p. 10 of [2]). The divisor function lies at the heart of a number of open number theoretical problems, e.g. the additive divisor problem of finding the asymptotic of

$$\begin{aligned} \sum _{n\le x} d_j(n)\quad d_j(n+h) \end{aligned}$$
(1)

for large x, which is notoriously difficult if \(j \ge 3\), see e.g. [1, 8], and, for \(j=3\), [7].

In the present paper, we consider the rather less well-studied jth non-trivial divisor function\(c_j\), which counts the ordered proper factorisations of a positive integer into j factors, each of which is greater than or equal to 2. While \(d_j(n)\), for given n, is obviously monotone increasing in j, since factors of 1 can be freely introduced, \(c_j(n)\) will shrink back to 0 as j gets too large, and indeed \(c_j(n) = 0\) if \(n < 2^j\).

Additionally, we define the associated divisor function\(c_j^{(r)}\), for \(r \in \mathbb {N}_0\), by

$$\begin{aligned} c_j^{(0)}= c_j, \qquad c_j^{(r)}(n) = \sum _{m|n}c^{(r-1)}_j(m)\quad (n, r\in \mathbb {N}). \end{aligned}$$

This definition is motivated by the sum-over divisors recurrence (3) for \(d_j\).

The paper is organised as follows. In Sect. 2, after reviewing properties of \(d_j\), we proceed to study analogous properties of \(c_j\), specifically regarding its associated Dirichlet series and its representation in terms of binomial coefficient sums and hypergeometric series. A major complication in comparison to \(d_j\) arises from the fact that \(c_j\) is not multiplicative. We also provide formulae expressing \(c_j\) in terms of \(d_j\) and vice versa. We then introduce the associated divisor functions \(c_j^{(r)}\). Noting general inequalities between the three types of divisor function in Sect. 3, we observe how their ratios can be expressed as binomial coefficient sums and hypergeometric series, and find explicit Dirichlet series and Euler products for some of these. As an illustrative application of the non-trivial and associated divisor functions, we show in Sect. 4 how they can be used to count principal reversible squares [10] and sum-and-distance systems of integers.

Throughout the paper, we use the notations \(\mathbb {N} = \{1, 2, 3, \ldots \}\), \(\mathbb {N}_0~=~\mathbb {N}~\cup ~\{0\}\). For n having prime factorisation \(n~=~ p_1^{a_1} p_2^{a_2} \cdots p_t^{a_t}\), we also use the symbol \(\varOmega (n) = \sum _{k=1}^t a_k\) .

2 Basic properties of standard, non-trivial and associated divisor functions

In view of the formula for the j-fold Dirichlet convolution of arithmetic functions \(f_1, f_2, \ldots , f_j\),

$$\begin{aligned} (f_1 * f_2 * \cdots * f_j)(n) = \sum _{\prod _{k=1}^j n_k = n}\ \prod _{k=1}^j f_k(n_k) \qquad (n \in \mathbb {N}), \end{aligned}$$
(2)

it is obvious that \(d_j = 1^{*j}\), where 1 denotes the constant function and the convolution power \(f^{*j}\) is (2) with \(f_1 = \cdots = f_j = f\). In particular, \(d_j\) satisfies the sum-over-divisors recurrence relation

$$\begin{aligned} d_{j+1}(n) = (d_j * 1)(n) = \sum _{m|n}d_j(m) \qquad (n,j \in \mathbb {N}) \end{aligned}$$
(3)

and has the Dirichlet series

$$\begin{aligned} \sum _{n=1}^\infty \frac{d_j(n)}{n^s} = \zeta (s)^j. \end{aligned}$$

These statements extend to the case \(j = 0\) if we set \(d_0 = e\), where e is defined as

$$\begin{aligned} e(n)=\left\{ \begin{array}{cc} 1 &{} \quad \text {if}\ n =1 \\ 0 &{} \quad \text {if}\ n>1 \end{array}\right. \qquad (n\in \mathbb {N}). \end{aligned}$$

The following explicit expression for \(d_j(n)\) in terms of the prime factorisation of n shows that \(d_j\) is a multiplicative arithmetic function; however, it is not totally multiplicative, e.g. \(d_3(20) = 18 \ne 27 = d_3(2) d_3(10)\).

Lemma 1

Let \(p_1, \ldots , p_t\) be distinct primes, \(t\in \mathbb {N}\). Then, for any \(j\in \mathbb {N}\),

$$\begin{aligned} d_j(p_1^{a_1} p_2^{a_2} \ldots p_t^{a_t}) = \prod _{k=1}^{t} {a_k +j -1 \atopwithdelims ()a_k} \quad (a_1, \ldots , a_t\in \mathbb {N}_0). \end{aligned}$$
(4)

Proof

(by induction on j) For \(j=1\) the formula is trivial. Suppose \(j\in \mathbb {N}\) is such that (4) holds. Note that \(m | \prod _{i=1}^k p_i^{a_i}\) if and only if \(m = \prod _{i=1}^k p_i^{{\tilde{a}}_i}\) with \(0 \le {\tilde{a}}_i \le a_i\) for all \(i \in \{1, \ldots , k\}\). Using multi-index notation, we can write the latter condition in the form \(0 \le {\tilde{a}} \le a\). By (3),

$$\begin{aligned} d_{j+1}(p_1^{a_1} \cdots p_k^{a_k})&= \sum _{0 \le {\tilde{a}} \le a} \prod _{i=1}^k {{\tilde{a}}_i + j-1 \atopwithdelims (){\tilde{a}}_i} \\&= \prod _{i=1}^k \sum _{l=0}^{a_i} {l + j-1 \atopwithdelims ()l} = \prod _{i=1}^k {a_i + j \atopwithdelims ()a_i}, \end{aligned}$$

using combinatorial identity (1.49) of [3] in the last step. \(\square \)

Remark 1

We remark that there are other known Dirichlet series associated with \(d_j\) (see for example [5], Chap. XVII]), such as

$$\begin{aligned} \frac{\zeta (s)^3}{\zeta (2s)} =\sum _{n=1} ^{\infty }\frac{d_2(n^2)}{n^s}, \qquad \text {and} \qquad \frac{\zeta (s)^4}{\zeta (2s)} =\sum _{n=1}^\infty \frac{\left( d_2(n)\right) ^2}{n^s}, \end{aligned}$$

both of which can be obtained from the more general calculation

$$\begin{aligned} \frac{\zeta (s)^{r+2}}{\zeta (2s)}&=\prod _p \frac{(1-p^{-s})(1+p^{-s})}{(1-p^{-s})(1-p^{-s})^{r+1}} =\prod _p (1+p^{-s})\sum _{j=0}^\infty \frac{(j+r)!}{j!r!}p^{-sj} \\&=\prod _p \left( 1+\sum _{j=1}^\infty \left( \frac{(j+r)!}{j!r!} + \frac{(j+r-1)!}{(j-1)!r!}\right) p^{-sj}\right) \\&=\prod _p\sum _{j=0}^\infty \frac{(2j+r)(j+r-1)!}{j!r!}p^{-sj}=\sum _{n=0}^\infty \frac{f_r(n)}{n^s}, \end{aligned}$$

where we use the Euler product for the zeta function and Newton’s inverse binomial series in the first two steps, respectively, and \(f_r\) is the multiplicative arithmetic function

$$\begin{aligned} f_r(p_1^{a_1}p_2^{a_2}\ldots p_t^{a_t})=\prod _{j=1}^t\frac{(2a_j+r)(a_j+r-1)!}{r!a_j!}. \end{aligned}$$

The non-trivial divisor function \(c_j\) only counts ordered factorisations in which all factors are greater than 1, so by formula (2) it can be expressed as the j-fold Dirichlet convolution \(c_j = (1 - e)^{*j}\). Hence it satisfies a slightly different sum-over-divisors recurrence relation compared to (3),

$$\begin{aligned} c_{j+1}(n)&= (c_j * (1 - e))(n) = \sum _{m | n} c_j(m) \,(1-e)\left( \frac{n}{m}\right) \nonumber \\&= \sum _{m|n, m<n} c_j(m) \qquad (n, j \in \mathbb {N}). \end{aligned}$$
(5)

As the Dirichlet series for \(1 - e\) is \(\zeta (s) - 1\), the non-trivial divisor function \(c_j\) has the Dirichlet series

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{c_j(n)}{n^s} = \left( \zeta (s)-1\right) ^j. \end{aligned}$$

These formulae extend to \(j = 0\) when we set \(c_0 = e\ (= d_0)\).

We emphasise that \(c_j\), unlike \(d_j\), is not a multiplicative arithmetic function. For example, \((2,5)=1\), and yet \(c_2(10)=2\ne 0 \times 0 = c_2(2) c_2(5).\)

In order to study the less symmetric multiplicative properties of \(c_j\), it is useful to express it in terms of its multiplicative cousin \(d_j\). When \(j=2\), the non-trivial divisors for any n are all the divisor except 1 and n, and hence \(c_2(n)=d_2(n)-2\) if \(n \ge 2\), and \(c_2(1) = d_2(1) - 1=0\). More generally, there is the following connection between the divisor function and the non-trivial divisor function.

Lemma 2

For \(j\in \mathbb {N}_0\),

$$\begin{aligned} c_j= \sum ^{j}_{i=0}(-1)^{j-i} {j\atopwithdelims ()i} d_i \qquad \hbox {and} \qquad d_j= \sum _{i=0}^{j} {j \atopwithdelims ()i} c_{i} . \end{aligned}$$

Proof

The first identity follows from applying the binomial theorem to the j-fold Dirichlet convolution,

$$\begin{aligned} c_j = (1 - e)^{*j} = \sum _{k=0}^j {j \atopwithdelims ()k} 1^{*k} * (-e)^{*(j-k)}, \end{aligned}$$

and using the fact that e is the identity for the convolution product. The proof of the second identity is analogous, starting from \(d_j = ((1-e)+e)^{*j}\). \(\square \)

We now derive a hypergeometric series for \(c_j(n)\). The generalised hypergeometric series has the form

$$\begin{aligned} _{k}F_n (a_1,a_2, \ldots , a_k; b_1,b_2,\ldots , b_n;z)= \sum _{m=0}^{\infty } \frac{a_1^{\overline{m}} \ a_2^{\overline{m}}\cdots a_k^{\overline{m}}\,z^m}{b_1^{\overline{m}} \ b_2^{\overline{m}}\cdots b_n^{\overline{m}}\,m!}, \end{aligned}$$

where \(a^{\overline{m}}\), with \(m\in \mathbb {N}\), is the Pochhammer symbol (rising factorial)

$$\begin{aligned} a^{\overline{m}} = \prod _{j=0}^{m-1}(a+j); \end{aligned}$$

in particular, \(1^{\overline{m}} = m!\), \(2^{\overline{m}} = (m+1)!\), \(a^{\overline{m}} = (a+m-1)!/(a-1)!\) if \(a\in \mathbb {N}\) and, for negative a, \(a^{\overline{m}} = (-1)^m\,(-a)!/(-a-m)!\) if \(-(a+m)\in \mathbb {N}_0\). By the usual convention on empty products, \(a^{\overline{0}} =1 \).

Theorem 1

Let \(j\in \mathbb {N}\) and suppose n has the prime factorisation \(n=p_1^{a_1}\ldots p_k^{a_k}\). Then the value of the non-trivial jth divisor function at n has the hypergeometric form

$$\begin{aligned} c_j(p_1^{a_1}\cdots p_k^{a_k})=(-1)^{1-j}j\,_{k+1}F_{k}\left( \{a_i+1\}^{k}_{i=1},(1-j);\{1\}_{i=1}^{k-1},2;1\right) . \end{aligned}$$

Proof

Starting from the right-hand side expression, we find

$$\begin{aligned}&(-1)^{1-j}j \sum _{m=0}^{\infty }\frac{\left( \prod _{i=1}^k (a_i+1)^{\overline{m}}\right) (1-j)^{\overline{m}}}{(1^{\overline{m}})^{k-1}\,2^{\overline{m}}\,m!} \\&\quad = (-1)^{1-j} \sum ^{j-1}_{m=0}\frac{j\,(j-1)!\,(-1)^m}{(m+1)!\,(j-m-1)!}\prod _{i=1}^k\frac{(a_i+m)!}{a!\,m!} \\&\quad = \sum ^{j-1}_{m=0}(-1)^{m-j+1} {j \atopwithdelims ()m+1}\prod _{i=1}^k {a_i+m \atopwithdelims ()m} \\&\quad = \sum ^{j-1}_{m=0}(-1)^{m-j+1} {j \atopwithdelims ()m+1}d_{m+1}(p_1^{a_1}\cdots p_k^{a_k}) =c_j(p_1^{a_1}\cdots p_k^{a_k}), \end{aligned}$$

by Lemmata 1 and 2. \(\square \)

In particular, for a prime power the above theorem gives

$$\begin{aligned} c_j(p^a)= (-1)^{1-j}j \,_{2}F_1(a+1,1-j;2;1)= (-1)^{1-j}j \sum _{m=0}^{\infty }\frac{(a+1)^{\overline{m}}(1-j)^{\overline{m}}}{2^{\overline{m}}\,m!}. \end{aligned}$$

Finally, we note the following multiplication rule for prime powers.

Lemma 3

Let p be a prime and \(j, a, b \in \mathbb {N}\). Then

$$\begin{aligned} c_j(p^{a+b})&=\sum ^{j-1}_{k=0} (-1)^{k-j+1} {j \atopwithdelims ()k+1 } d_{k+1}(p^b)\frac{(b+k+1)^{\overline{a}}}{(b+1)^{\overline{a}}} . \end{aligned}$$

Proof

By Lemma 1,

$$\begin{aligned} \frac{d_j(p^{a+b})}{d_j(p^b)}&= \frac{(a+b+j-1)!\,b!\,(j-1)!}{(a+b)!\,(j-1)!\,(b+j-1)!} = \frac{(b+j)^{\overline{a}}}{(b+1)^{\overline{a}}}. \end{aligned}$$

The statement now follows by combining this result with Lemma 2. \(\square \)

In analogy to the sum-over-divisors recurrence relation (3) for the divisor function \(d_j\), we define the jth associated divisor function \(c_j^{(r)} \) by the following recurrence.

Definition 1

Let \(j\in \mathbb {N}\). Then, for all non-negative integers r, the associated divisor function\(c_j^{(r)}\) is defined recursively by

$$\begin{aligned} c_j^{(0)}(n)= c_j(n), \qquad c_j^{(r)}(n) = \sum _{m|n}c^{(r-1)}_j(m) = (c_j^{(r-1)} * 1)(n) \qquad (n\in \mathbb {N}). \end{aligned}$$

This immediately gives the representation \(c_j^{(r)} = (1 - e)^{*j} * 1^{*r}\). Thus, we can interpret \(c_j^{(r)}(n)\) as the number of ordered factorisations of n into \(j+r\) factors, the first j of which are greater than 1. It follows that \(c_j^{(r)}(n) = 0\) for all \(r\in \mathbb {N}\) if \(n < 2^j\).

The Dirichlet series of the associated divisor function \(c_j^{(r)}\) is

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{c_j^{(r)}(n)}{n^s} = \zeta (s)^r (\zeta (s) -1)^j. \end{aligned}$$

The following formulae representing the associated divisor functions in terms of the usual divisor functions and in terms of the non-trivial divisor functions can be obtained by applying the binomial theorem to the first convolution power in \(c_j^{(r)} = (1-e)^{*j} * 1^{*r}\) and to the second convolution power in \(c_j^{(r)} = (1-e)^{*j} * ((1-e) + e)^{*r}\), respectively.

Lemma 4

Let \(j\in \mathbb {N}\) and \(r\in \mathbb {N}_0\). Then

$$\begin{aligned} c_j^{(r)}= \sum _{i=0}^j (-1)^{j-i} {j \atopwithdelims ()i} d_{i+r}, \qquad c_j^{(r)}= \sum _{i=0}^r { r \atopwithdelims ()i} c_{j+i}. \end{aligned}$$

The following binomial form for the value of \(c_j^{(r)}\) at prime powers is somewhat analogous to Lemma 1, but note that the present function is not multiplicative.

Lemma 5

Let \(j, a \in \mathbb {N}\), \(r \in \mathbb {N}_0\) and p a prime. Then

$$\begin{aligned} c_j^{(r)}(p^a)=\left( {\begin{array}{c}a+r-1\\ j+r-1\end{array}}\right) . \end{aligned}$$

Proof

From Lemmata 4 and 1, we find

$$\begin{aligned} c^{(r)}_j(p^a) = \sum _{i=0}^j (-1)^{j-i} {j \atopwithdelims ()i} {a +i+r -1 \atopwithdelims ()a} = {a + r - 1 \atopwithdelims ()a - j} = {a + r -1 \atopwithdelims ()j + r - 1} \end{aligned}$$

by combinatorial identity (3.47) of [3]. \(\square \)

We conclude this section with a remark on the generating functions for the different types of divisor function considered above. If we denote the generating function of an arithmetic function f by Gf, so

$$\begin{aligned} Gf(x) = \sum _{n=1}^\infty f(n)\,x^n \end{aligned}$$

for all \(x\in \mathbb {C}\) for which the power series converges, then the following recursive identities hold for \(j, r \in \mathbb {N}_0\),

$$\begin{aligned} Gd_{j+1}(x)= & {} \sum _{k=1}^\infty Gd_j(x^k), \qquad Gc_{j+1}(x) = \sum _{k=1}^\infty Gc_j(x^k), \\ Gc_j^{(r+1)}(x)= & {} \sum _{k=1}^\infty Gc_j^{(r)}(x^k). \end{aligned}$$

These follow from the observation that if \(f = g * 1\) for some arithmetic functions fg, then

$$\begin{aligned} Gf(x) = \sum _{n=1}^\infty \sum _{m|n} g(m)\,x^n = \sum _{k=1}^\infty \sum _{m=1}^\infty g(m)\,(x^k)^m, \end{aligned}$$
(6)

and if \(f = g * (1-e)\), then

$$\begin{aligned} Gf(x) = \sum _{n=1}^\infty \sum _{m|n, m < n} g(m)\,x^n = \sum _{k=2}^\infty \sum _{m=1}^\infty g(m)\,(x^k)^m. \end{aligned}$$
(7)

We note in passing that upon reversal of the order of the sums, Eqs. (6) and (7) also yield

$$\begin{aligned} Gf(x) = \sum _{m=1}^\infty g(m)\,\frac{x^m}{1 - x^m} \qquad \hbox {and}\qquad Gf(x) = \sum _{m=1}^\infty g(m)\,\frac{x^{2m}}{1 - x^m}, \end{aligned}$$

respectively, provided \(x \ne 1\); however, the right-hand side is then not of the form of a generating function.

3 Ratios of divisor functions

The divisor function, non-trivial divisor function and associated divisor functions satisfy the following ordering relations.

Lemma 6

For any \(j\in \mathbb {N}\) and \(r\in \mathbb {N}\),

$$\begin{aligned} c_j^{(r-1)}(n) \le c_j^{(r)}(n); \end{aligned}$$

in particular,

$$\begin{aligned} c_j(n) \le c_j^{(r)}(n) \qquad (n\in \mathbb {N}). \end{aligned}$$

Moreover,

$$\begin{aligned} c_j^{(r)}(n) \le d_{j+r}(n) \qquad (n\in \mathbb {N}). \end{aligned}$$

Proof

For the first statement, it is sufficient to note that n|n, so

$$\begin{aligned} c_j^{(r)}(n) = \sum _{m|n} c_j^{(r-1)}(m) \ge c_j^{(r-1)}(n) \qquad (n\in \mathbb {N}). \end{aligned}$$

The final statement follows from the facts that \(1 - e \le 1\) and that the Dirichlet convolution of non-negative functions is monotonic in each factor. \(\square \)

Lemma 6 shows that, for any \(r\in \mathbb {N}_0\), the normalised divisor ratio function \(c_j^{(r)}/d_{j+r}\) takes rational values between 0 and 1, with the zeros occurring exactly when \(j>\varOmega (n)\). We have the following formulae for this function and the similar ratio \(c_j^{(r)}/d_r\).

Theorem 2

Let \(j\in \mathbb {N}\) and \(r\in \mathbb {N}_0\), and suppose \(n\in \mathbb {N}\) has prime factorisation \(n=p_1^{a_1} \cdots p_t^{a_t} \). Then

$$\begin{aligned} \frac{c_j^{(r)}(n)}{d_{j+r}(n)}&= \sum _{i=0}^j (-1)^i {j \atopwithdelims ()i} \frac{{ j+r-1 \atopwithdelims ()i}^t}{\prod _{k=1}^t {a_k +j +r -1 \atopwithdelims ()i}} \nonumber \\&= {}_{t+1}F_t(\{1-j-r\}_{i=1}^t,-j;\{1-a_i-j-r \}^{t}_{i=1};1). \end{aligned}$$
(8)

Also, for \(r \ge 1\)

$$\begin{aligned} \frac{c_j^{(r)}(n)}{d_{r}(n)}&= \sum _{i=0}^j (-1)^{j-i} \left( {\begin{array}{c}j\\ i\end{array}}\right) \frac{\prod _{k=1}^{t} \left( {\begin{array}{c}a_k+i+r-1\\ i\end{array}}\right) }{\left( {\begin{array}{c}i+r-1\\ i\end{array}}\right) ^{t}} \nonumber \\&= (-1)^{j}\ {}_{t+1}F_{t}(\{a_k+r\}^{t}_{k=1},-j;\{r\}_{k=1}^{t};1). \end{aligned}$$
(9)

Proof

By Lemmata 4 and 1, we have that

$$\begin{aligned} c_j^{(r)}(n)&=\sum _{i=0}^{j}(-1)^i {j \atopwithdelims ()i} d_{j+r-i}(n)= \sum _{i=0}^{j}(-1)^i {j \atopwithdelims ()i}\prod _{k=1}^t \frac{(a_k +j+r-1-i)!}{(j+r-i-1)!\, a_k!} \nonumber \\&=\sum _{i=0}^{j}(-1)^i {j \atopwithdelims ()i}\prod _{k=1}^{t} \frac{ {j+r-1 \atopwithdelims ()i} {a_k+j +r -1 \atopwithdelims ()j+r-1} }{{a_k +j +r -1 \atopwithdelims ()i }} \nonumber \\&=\left( \prod _{k=1}^{t} {a_k+j+r-1 \atopwithdelims ()j+r-1}\right) \sum _{i=0}^{j}(-1)^i {j \atopwithdelims ()i} \frac{{j+r-1 \atopwithdelims ()i }^t}{\prod _{k=1}^t {a_k+j+r-1 \atopwithdelims ()i}} \nonumber \\&=d_{j+r}(n) \sum _{i=0}^j (-1)^i {j \atopwithdelims ()i} \frac{{ j+r-1 \atopwithdelims ()i}^t}{\prod _{k=1}^t {a_k +j +r -1 \atopwithdelims ()i}}. \end{aligned}$$
(10)

To obtain the hypergeometric form, we note that

$$\begin{aligned} \frac{c_j^{(r)}(n)}{d_{j+r}(n)}&= \sum _{i=0}^j \frac{(-j)^{{\overline{i}}}}{i!}\,\frac{\left( \frac{(j+r-1)!}{(j+r-1-i)!}\right) ^t}{\prod _{k=1}^t \frac{(j+r+a_k-1)!}{(j+r+a_k-1-i)!}} = \sum _{i=0}^\infty \frac{(-j)^{{\overline{i}}}}{i!}\,\frac{\left( (-1)^i (1-j-r)^{{\overline{i}}}\right) ^t}{\prod _{k=1}^t (-1)^i (1-j-r-a_k)^{{\overline{i}}}} \\&= {}_{t+1}F_t\left( \{1-j-r\}_{k=1}^t, -j; \{1-a_k-j-r\}_{k=1}^t; 1\right) , \end{aligned}$$

establishing (8). For the proof of (9), we rewrite (10) in the form

$$\begin{aligned} c_j^{(r)}(n)&= \sum _{i=0}^j (-1)^{j-i} {j \atopwithdelims ()i} \prod _{k=1}^t \frac{(a_k+i+r-1)!}{(i+r-1)!\,a_k!} \\&= \left( \prod _{k=1}^t \frac{(a_k+r-1)!}{a_k!\,(r-1)!}\right) \sum _{i=0}^j (-1)^{j-i} {j \atopwithdelims ()i} \\&\quad \times \prod _{k=1}^t \left( \frac{(a_k+r-1+i)!}{(a_k+r-1)!\,i!}\,\frac{i!\,(r-1)!}{(i+r-1)!}\right) \end{aligned}$$

and apply Lemma 1. For the hypergeometric form, we rewrite the last expression as

$$\begin{aligned} \frac{c_j^{(r)}(n)}{d_r(n)}&= (-1)^j \sum _{i=0}^j \frac{(-j)^{{\overline{i}}}}{i!}\,\prod _{k=1}^t \frac{(a_k +r)^{{\overline{i}}}}{r^{{\overline{i}}}} \end{aligned}$$

and note as above that the sum can be extended to an infinite series since \((-j)^{{\overline{i}}} = 0\) if \(i > j\). \(\square \)

Specifically for \(r=0\), the formula (8) of Theorem 2 gives

$$\begin{aligned} \frac{c_j(n)}{d_{j}(n)}&= \sum _{i=0}^j (-1)^i {j \atopwithdelims ()i} \frac{{ j-1 \atopwithdelims ()i}^t}{\prod _{k=1}^t {a_k +j -1 \atopwithdelims ()i}} \\&= {}_{t+1}F_t(\{1-j\}_{i=1}^t,-j;\{1-a_i-j \}^{t}_{i=1};1) \end{aligned}$$

if n has prime factorisation \(n = p_1^{a_1}\cdots p_t^{a_t}\).

Clearly these formulae simplify when n is a prime power. We note that in this case, Lemmata 1 and 5 give

$$\begin{aligned} \frac{c_j(p^a)}{d_j(p^a)} = \frac{\left( {\begin{array}{c}a-1\\ a-j\end{array}}\right) }{\left( {\begin{array}{c}a+j-1\\ a\end{array}}\right) }. \end{aligned}$$

In the following, we give Dirichlet series for the ratio of divisor functions \(c_j/d_j\) for \(j\in \{1, 2, 3\}\), as well as corresponding Euler products. Note that the term \(n=1\) can be omitted from the Dirichlet series, since \(c_j(1) = 0\) for all \(j\in \mathbb {N}\). For \(j=1\),

$$\begin{aligned} \sum _{n=2}^{\infty } \frac{c_1(n)}{d_1(n)}\frac{1}{n^s} = \sum _{n=2}^{\infty } \frac{1}{n^s} = \zeta (s) -1 . \end{aligned}$$

For \(j=2\), we have \(c_2(n) = d_2(n) -2 \) for \(n \ge 2 \), so the Dirichlet series for the ratio of divisor functions can be written as

$$\begin{aligned} \sum _{n=2}^{\infty } \frac{c_2(n)}{d_2(n)}\,\frac{1}{n^s}= & {} \sum _{n=2}\frac{1}{n^s} - 2 \sum _{n=2}^{\infty } \frac{1}{d_2(n) n^s}\\= & {} 1 + \zeta (s) - 2 \sum _{n=1}^{\infty } \frac{1}{d_2(n)n^s}; \end{aligned}$$

we note the Euler product for the Dirichlet series in the last term,

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{1}{d_2(n)\,n^s}&= \prod _{p \ \mathrm{prime}} \sum _{j=0}^\infty \frac{1}{d_2(p^j)\,p^{sj}} = \prod _{p \ \mathrm{prime}} \sum _{j=0}^\infty \frac{1}{(j+1)\,p^{sj}} \\&= \prod _{p \ \mathrm{prime}} \left( p^s \log \left( \frac{1}{1-\frac{1}{p^s}} \right) \right) . \end{aligned}$$

For \(j=3 \), we have \(c_3(n)= d_3(n) - 3d_2(n) + 3\) for \(n \ge 2\), which gives the Dirichlet series for the ratio of divisor functions

$$\begin{aligned} \sum _{n=2}^{\infty } \frac{c_3(n)}{d_3(n)}\,\frac{1}{n^s} = \zeta (s) - 1 - 3 \sum _{n=1}^{\infty } \frac{d_2(n)}{d_3(n)}\frac{1}{n^s} + 3 \sum _{n=1}^{\infty }\frac{1}{d_3(n)}\frac{1}{n^s}; \end{aligned}$$

noting

$$\begin{aligned} \frac{d_2(p^j)}{d_3(p^j)} = \frac{2}{j+2}, \ \frac{1}{d_3(p^j)} = \frac{2}{(j+1)(j+2)} = \frac{2}{j+1} - \frac{2}{j+2}, \end{aligned}$$

we find the Euler products

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{d_2(n)}{d_3(n)}\frac{1}{n^s}&= \prod _{p \ \mathrm{prime}} \sum _{j=0}^\infty \frac{2}{(j+2)\,p^{sj}} = \prod _{p \ \mathrm{prime}} \sum _{j=2}^\infty \frac{2 p^{2s}}{j\,p^{sj}}\\&= \prod _{p \ \mathrm{prime}} 2p^{2s}\left( \log \left( \frac{1}{1- \frac{1}{p^s}}\right) - \frac{1}{p^s} \right) \end{aligned}$$

and

$$\begin{aligned} \sum _{n=1}^{ \infty } \frac{1}{d_3(n)}\frac{1}{n^s}&= \prod _{p \ \mathrm{prime}} \sum _{j=0}^\infty \left( \frac{2}{j+1} - \frac{2}{j+2}\right) \frac{1}{p^{sj}} \\&= \prod _{p \ \mathrm{prime}} \left( \sum _{j=1}^\infty \frac{2 p^s}{j p^{sj}} - \sum _{j=2}^\infty \frac{2 p^{2s}}{j p^{sj}}\right) \\&= \prod _{p \ \mathrm{prime}} \left( 2 p^s \log \frac{1}{1 - \frac{1}{p^s}} - 2 p^{2s}\left( \log \frac{1}{1-\frac{1}{p^s}} - \frac{1}{p^s}\right) \right) \\&= \prod _{p \ \mathrm{prime}} 2 p^{2s} \left( \frac{1}{p^s} - \left( 1 - \frac{1}{p^s}\right) \log \frac{1}{1 - \frac{1}{p^s}}\right) . \end{aligned}$$

4 Counting principal reversible squares

As an illustration for the use of the non-trivial and associated divisor functions, we show how they can be used to count the different principal reversible squares of a given size.

A reversible square matrix\(M=\left( M_{i,j}\right) _{i,j \in \mathbb {Z}_n} \in \mathbb {R}^{n\times n}\) is an \(n \times n\) matrix with the following symmetry properties (cf. [10, 9]),

  1. (R)

    the row and column reversal symmetry

    $$\begin{aligned} M_{i,j} +M_{i,n+1-j}&=M_{i,k} +M_{i,n+1-k}, \\ M_{i,j}+M_{n+1-i,j}&=M_{k,j}+M_{n+1-k,j} \qquad (i,j,k \in \mathbb {Z}_n), \end{aligned}$$
  2. (V)

    the vertex cross sum property \(M_{i,j}+M_{k,l}=M_{i,l}+M_{k,j}\)\((i,j,k,l \in \mathbb {Z}_n)\).

Note that the index calculations are performed in the cyclic ring \(\mathbb {Z}_n := \mathbb {Z}/{n \mathbb {Z}}\), and the top left corner of the matrix has indices \((1,1) \in \mathbb {Z}_n^2\).

An \(n\times n\)principal reversible square is a reversible square matrix M such that \(\{M_{i,j}\mid i,j\in \mathbb {Z}_n\} = \{1,2, \ldots , n^2\}\), the entries in each row and each column appear in increasing order, and \(M_{1,j} = j\) (\(j\in \{1,2\}\)).

Definition 2

Let \(n, \alpha \in \mathbb {N}\). The pair of tuples

$$\begin{aligned} ((i_1, i_2, \ldots , i_{\alpha -1}, i_\alpha ), \ (j_1, j_2, \ldots , j_{\alpha -1}, j_{\alpha })) \in (\mathbb {N}^\alpha )^2 \end{aligned}$$

is called a divisor path set for n (of length \(\alpha \)) if

$$\begin{aligned} i_1 | i_2 | \ldots | i_{\alpha -1}| i_{\alpha }, \qquad 1< i_1<i_2< \cdots< i_{\alpha -1}<i_{\alpha }= n, \end{aligned}$$

and

$$\begin{aligned} j_1 | j_2 | \ldots | j_{\alpha -1}| j_{\alpha } | n, \qquad 1< j_1< j_2< \cdots<j_{\alpha -1} < j_{\alpha } \le n. \end{aligned}$$

Theorem 3

Let \(n \in \mathbb {N}\). Then from any divisor path set for n, a unique \(n\times n\) principal reversible square can be constructed. Conversely, every \(n\times n\) principal reversible square arises from a unique divisor path set.

For the details of the construction and proof of Theorem 3, we refer the reader to Chap. 3 of [10]. In that book, a principal reversible square constructed from a divisor path set of length \(\alpha \) is said to have \(\alpha -1\)progressive factors.

Alternatively, Theorem 3 and the construction can be obtained as a special case, for a two-dimensional square array, of Theorem 9 of [6]; note that the ratios of consecutive divisors in the divisor path set correspond to the factors appearing in the joint ordered factorisation defined in [6]. Specifically, the above divisor path set corresponds to the joint ordered factorisation

$$\begin{aligned}&((2,j_1), (1,i_1), (2,j_2/j_1), (1,i_2/i_1), (2,j_3/j_2), \ldots , \\&\quad (2,j_\alpha /j_{\alpha -1}), (1,i_\alpha /i_{\alpha -1}), (2,n/j_\alpha )) \end{aligned}$$

of (nn), with the last entry omitted if \(j_\alpha = n.\)

Using the bijection between divisor path sets and principal reversible squares given by Theorem 3, we can count the number of different principal reversible squares of size \(n\times n\) in terms of the non-trivial and associated divisor functions of n as follows.

Theorem 4

Let \(n\in \mathbb {N}\). The number of different \(n\times n\) principal reversible squares is given by

$$\begin{aligned} N_n =\sum _{j=1}^{\varOmega (n)}c_j^{(0)}(n)c_j^{(1)}(n) =\sum _{j=1}^{\varOmega (n)}c_j(n)\left( c_j(n)+c_{j+1}(n)\right) . \end{aligned}$$

Proof

By Theorem 3, it is sufficient to count the number of different divisor path sets for n.

Suppose \(((i_1, \ldots , i_\alpha ), (j_1, \ldots , j_\alpha ))\) is a divisor path set for n of length \(\alpha \). Then the left-hand tuple gives an ordered factorisation of n into \(\alpha \) factors,

$$\begin{aligned} i_1 \ \frac{i_2}{i_1} \ \frac{i_3}{i_2} \ \cdots \ \frac{i_\alpha }{i_{\alpha -1}} = n \end{aligned}$$

with all factors \(> 1\); there are \(c_\alpha (n)\) such non-trivial factorisations.

The right-hand tuple gives an ordered factorisation of n into \(\alpha +1\) factors,

$$\begin{aligned} j_1 \ \frac{j_2}{j_1} \ \frac{j_3}{j_2} \ \cdots \ \frac{j_\alpha }{j_{\alpha -1}} \ \frac{n}{j_\alpha } = n, \end{aligned}$$

where the last factor may or may not be equal to 1 and all other factors are \(> 1\); there are \(c_\alpha ^{(1)}(n)\) such factorisations.

The statement of the theorem follows by summing over \(\alpha \in \mathbb {N}\), noting that \(c_\alpha (n) = 0\) if \(\alpha > \varOmega (n)\), and using Lemma 4 for the last identity. \(\square \)

Remark 2

Combining the formula of Theorem 4 with Lemma 4, the count \(N_n\) can be expressed in terms of the (multiplicative) divisor functions,

$$\begin{aligned} N_n=\sum _{j=1}^{\varOmega (n)} \sum _{l=1}^j \sum _{m=0}^{j} (-1)^{l+m} \left( {\begin{array}{c}j\\ l\end{array}}\right) \left( {\begin{array}{c}j\\ m\end{array}}\right) d_l(n) d_{m+1}(n). \end{aligned}$$
(11)

Using the prime factorisation \(n = \prod _{k=1}^t p_k^{a_k}\), this takes the form

$$\begin{aligned} N_n=\sum _{j=1}^{\varOmega (n)} \sum _{l=1}^j \sum _{m=0}^{j} (-1)^{l+m} \left( {\begin{array}{c}j\\ l\end{array}}\right) \left( {\begin{array}{c}j\\ m\end{array}}\right) \prod _{k=1}^t {a_k +l -1 \atopwithdelims ()l-1} {a_k +m \atopwithdelims ()m}. \end{aligned}$$

We note that the terms of the sum in (11) bear some similarity to the sum underlying the additive divisor problem (1).

Corollary 1

Let \(n\in \mathbb {N}\). Then \(N_n = 1\) if and only if n is prime.

Proof

If n is prime, then \(c_1(n) = 1\) and \(c_j(n) = 0\) for all \(j\ge 2\), and it follows that \(N_{n}=c_1(n)\left( c_1(n)+c_{2}(n)\right) =1\). Conversely, suppose \(n \ge 2\) is an integer such that \(N_n = 1\). By Theorem 4,

$$\begin{aligned} N_n = \sum _{j=1}^{\varOmega (n)} c_j(n)^2 + \sum _{j=1}^{\varOmega (n)} c_j(n) c_{j+1}(n). \end{aligned}$$

As all terms of these sums are non-negative and \(c_1(n) = 1\), the total can equal 1 only if \(c_j(n) = 0\)\((j \ge 2)\), which implies that n is prime. \(\square \)

Corollary 2

Let \(n = p^a\) with \(a \in \mathbb {N}\) and prime p. Then

$$\begin{aligned} N_n=\left( {\begin{array}{c}2a-1\\ a\end{array}}\right) . \end{aligned}$$

Proof

Theorem 4 and Lemma 5 give

$$\begin{aligned} N_{p^a}=\sum _{j=1}^a \left( {\begin{array}{c}a-1\\ j-1\end{array}}\right) \left( {\begin{array}{c}a\\ j\end{array}}\right) =\sum _{j=0}^{a-1} \left( {\begin{array}{c}a-1\\ j\end{array}}\right) \left( {\begin{array}{c}a\\ j+1\end{array}}\right) = \left( {\begin{array}{c}2a-1\\ a\end{array}}\right) \end{aligned}$$

by combinatorial identity (3.20) of [3]. \(\square \)

Counting principal reversible squares is of interest not only in view of their bijection to most perfect squares [10], but also because of their relationship with sum-and-distance systems. In the present context, these are composed of two finite component sets, of equal cardinality, of natural numbers, such that the numbers formed by considering all sums and all absolute differences of all pairs of numbers, each taken from one of the component sets, with or without inclusion of the component sets themselves, combine to an arithmetic progression without repetitions. Such systems arise naturally from the question of constructing a certain type of rank 2 traditional magic squares using the formulae given in [9]. We refer the reader to [6] for further details and for the extension of the following definitions and of Theorem 5 to any finite number of component sets of arbitrary finite cardinality.

Definition 3

Let \(m\in \mathbb {N}\) and consider positive integers \(a_j, b_j \in \mathbb {N}\)\((j\in \{1,\ldots ,m\})\) such that

$$\begin{aligned} a_1< a_2< \cdots< a_m, \qquad b_1< b_2< \cdots < b_m. \end{aligned}$$

We call \(\{\{a_j : j\in \{1,\ldots ,m\}\}, \{b_j : j\in \{1,\ldots ,m\}\}\}\)

  1. (a)

    an \(m+m\)(non-inclusive) sum-and-distance system if

    $$\begin{aligned} \{a_j+b_k, |a_j-b_k| : j,k\in \{1,\ldots ,m\}\} = \{1, 3, 5, \ldots , 4m^2-1\}; \end{aligned}$$
  2. (b)

    an \(m+m\)inclusive sum-and-distance system if

    $$\begin{aligned} \{a_j, b_k, a_j+b_k, |a_j-b_k| : j,k\in \{1,\ldots ,m\}\} = \{1, 2, 3, \ldots , 2m(m+1)\}. \end{aligned}$$

It is easy to see that the conditions in a) and b) above are equivalent to

$$\begin{aligned}&\{\pm a_j : j\in \{1,\ldots , m\}\} + \{\pm b_k : k\in \{1,\ldots ,m\}\}\nonumber \\&\quad = \{-4m^2+1, -4m^2+3, \ldots , 4m^2-3, 4m^2-1\} \end{aligned}$$
(12)

and

$$\begin{aligned}&\{0, \pm a_j : j\in \{1,\,ldots,m\}\} + \{0, \pm b_k : k\in \{1,\ldots ,m\}\}\nonumber \\&\quad = \{-2m(m+1), -2m(m+1)+1, \ldots , 2m(m+1)\}, \end{aligned}$$
(13)

respectively, where we use the usual sum of sets \(A + B = \{x + y : x\in A, y\in B\}\).

Example 1

For \(m=3\) there are the seven \(3+3\) (non-inclusive) sum-and-distance systems

$$\begin{aligned}&\{\{ 1 , 3 , 5 \},\{ 6 , 18 , 30\}\},\quad \{\{ 1 , 7 , 9\}, \{2 , 22 , 26\}\},\quad \{\{1 , 11 , 13\}, \{14 , 18 , 22\}\}, \\&\{\{1 , 23 , 25\}, \{2 , 6 , 10\}\},\quad \{\{3 , 9 , 15\}, \{16 , 18 , 20\}\},\quad \{\{3 , 21 , 27\}, \{4 , 6 , 8\}\}, \\&\{\{7 , 9 , 11\}, \{12 , 18 , 24\}\}, \end{aligned}$$

but just the one inclusive \(3+3\) sum-and-distance system \(\{\{1 , 2 , 3\}, \{7 , 14 , 21\}\}\).

Sum-and-distance systems of the non-inclusive and inclusive variety are intimately connected with principal reversible squares. Indeed, let \(n\in \mathbb {N}\) and consider a principal reversible square \((M_{j,k})_{j,k\in \mathbb {Z}_n}\); for all \(j\in \{1,\ldots ,n\}\), define \(\alpha _j = M_{1,j} - 1\) and \({\beta _j = M_{j,1} - 1}\). From property (V) of the reversible square and the fact that \(M_{1,1}=1\), it then follows that

$$\begin{aligned} M_{j,k} = M_{j,1} + M_{1,k} - 1 = \alpha _j + \beta _k + 1 \qquad (j,k\in \{1,\ldots ,n\}); \end{aligned}$$
(14)

note that \(\alpha _1 = \beta _1 = 0\). By property (R),

$$\begin{aligned} \alpha _j + \alpha _{n+1-j} = \alpha _n, \quad \beta _j + \beta _{n+1-j} = \beta _n \qquad (j\in \{1, \ldots , n\}). \end{aligned}$$
(15)

Now suppose n is even, \(n = 2m\). Then setting

$$\begin{aligned} a_j = \alpha _{m+j} - \alpha _{m+1-j}, \quad b_j = \beta _{m+j} - \beta _{m+1-j} \qquad (j\in \{1, \ldots , m\}) \end{aligned}$$

defines an \(m+m\) non-inclusive sum-and-distance system. Indeed, it follows from (15) that

$$\begin{aligned} a_j = 2 \alpha _{m+j} - \alpha _n, \quad -a_j = 2 \alpha _{m+1-j} - \alpha _n \qquad (j\in \{1,\ldots ,m\}) \end{aligned}$$

and correspondingly for \(\pm b_k\)\((k\in \{1,\ldots ,m\})\), so the equality (12) can be verified using the facts that \(\alpha _n + \beta _n = M_{n,n}-1 = n^2-1\) and that

$$\begin{aligned} \{\alpha _j + \beta _k : j,k\in \{1,\ldots ,n\}\} = \{M_{j,k}-1 : j,k\in \{1,\ldots ,n\}\} = \{0, 1, \ldots , n^2-1\}. \end{aligned}$$

Conversely, given an \(m+m\) non-inclusive sum-and-distance system and setting

$$\begin{aligned} \alpha _{m+j} = \frac{a_m + a_j}{2},&\quad \alpha _{m+1-j} = \frac{a_m - a_j}{2} \qquad (j\in \{1,\ldots ,m\}), \\ \beta _{m+k} = \frac{b_m + b_k}{2},&\quad \beta _{m+1-k} = \frac{b_m - b_k}{2} \qquad (k\in \{1,\ldots ,m\}), \end{aligned}$$

Eq. (14) defines a principal reversible square (or its transpose).

Similarly, if \(n = 2m+1\) is odd, then an \(m+m\) inclusive sum-and-distance system can be obtained from any \(n\times n\) principal reversible square by setting

$$\begin{aligned} a_j = \frac{\alpha _{m+1+j}-\alpha _{m+1-j}}{2}, \quad b_j = \frac{\beta _{m+1+j}-\beta _{m+1-j}}{2} \qquad (j\in \{1,\ldots ,m\}); \end{aligned}$$

now by (15),

$$\begin{aligned} a_j = \alpha _{m+1+j} - \frac{\alpha _n}{2}, \quad -a_j = \alpha _{m+1-j} - \frac{\alpha _n}{2} \qquad (j\in \{1,\ldots ,m\}), \end{aligned}$$

and similarly for \(b_k\)\((k\in \{1,\ldots ,m\})\), and hence equality (13) follows in analogy to the above. Conversely, setting

$$\begin{aligned} \alpha _{m+1+j} = a_m + a_j, \quad \alpha _{m+1-j} = a_m - a_j \qquad (j\in \{1,\ldots , m\}), \\ \beta _{m+1+k} = b_m + b_k, \quad \beta _{m+1-k} = b_m - b_k \qquad (k\in \{1,\ldots , m\}) \end{aligned}$$

and \(\alpha _{m+1} = a_m\), \(\beta _{m+1} = b_m\), we obtain a principal reversible square (or its transpose), via (14), from an inclusive sum-and-distance system.

Thus, we have proven the following statement.

Theorem 5

Let \(m\in \mathbb {N}\). Then there is a bijection between the \(m+m\) non-inclusive sum-and-distance systems and the \(2m \times 2m\) principal reversible squares, and there is a bijection between the \(m+m\) inclusive sum-and-distance systems and the \((2m+1)\times (2m+1)\) principal reversible squares.

In conjunction with Theorem 4, this gives the following counting of non-inclusive and inclusive sum-and-distance systems.

Corollary 3

Let \(m\in \mathbb {N}\). Then there are

$$\begin{aligned} N_{2m} = \sum _{j=1}^{\varOmega (2m)} c_j^{(0)}(2m)\,c_j^{(1)}(2m) \end{aligned}$$

different \(m+m\) non-inclusive sum-and-distance systems, and

$$\begin{aligned} N_{2m+1} = \sum _{j=1}^{\varOmega (2m+1)} c_j^{(0)}(2m+1)\,c_j^{(1)}(2m+1) \end{aligned}$$

different \(m+m\) inclusive sum-and-distance systems.

To conclude, we briefly note that \(m+m\) sum-and-distance systems of either variety have the general property that the sum of squares of all entries of their component sets is invariant, determined only by the size m.

Theorem 6

Let \(m\in \mathbb {N}\) and \(\{\{a_1,\ldots ,a_m\},\{b_1,\ldots ,b_m\}\}\) a (non-inclusive or inclusive) sum-and-distance system. Then

$$\begin{aligned} \sum _{j=1}^m (a_j^2 + b_j^2) = \left\{ \begin{array}{ll} {\frac{1}{3!}}\,(2m)((2m)^4-1) &{} \quad \textit{in the non-inclusive case,} \\ {\frac{1}{4!}}\,(2m+1)((2m+1)^4-1) &{}\quad \textit{in the inclusive case.} \end{array}\right. \end{aligned}$$

Proof

In the non-inclusive case, we use the formula

$$\begin{aligned} \sum _{j=1}^n (2j-1)^2 = \frac{n (4n^2-1)}{3} \qquad (n\in \mathbb {N}) \end{aligned}$$

to find

$$\begin{aligned} 2m \sum _{j=1}^m (a_j^2 + b_j^2)&= \sum _{j=1}^m \sum _{k=1}^m ((a_j+b_k)^2 + (a_j-b_k)^2)\\&= \sum _{j=1}^{2m^2} (2j-1)^2 = \frac{1}{6}\, 4m^2(16m^4-1). \end{aligned}$$

In the inclusive case, we similarly use the formula

$$\begin{aligned} \sum _{j=1}^n j^2&= \frac{n(n+1)(2n+1)}{6} = \frac{(2n+1-1)(2n+1+1)(2n+1)}{24} \\&= \frac{((2n+1)^2-1)(2n+1)}{24} \qquad (n\in \mathbb {N}) \end{aligned}$$

and the identity for \(n=2m(m+1)\)

$$\begin{aligned} 2n+1 = 4m^2+4m+1 = (2m+1)^2 \end{aligned}$$

to calculate

$$\begin{aligned} (2m+1) \sum _{j=1}^m (a_j^2+b_j^2)&= \sum _{j=1}^m \sum {k} \\&=1^{m} ((a_j+b_j)^2 + (a_j-b_j)^2) + \sum _{j=1}^m a_j^2 + \sum _{j=1}^m b_j^2 \\&=\sum _{j=1}^{2m(m+1)} j^2 = \frac{1}{24}\,((2m+1)^4-1)\,(2m+1)^2. \end{aligned}$$

\(\square \)