1 Introduction

Theory of partitions is a classical part of number theory. Main arithmetical questions concerning counting functions of various types of partitions are related to divisibility properties and p-adic behavior for various values of \(p\in {\mathbb {P}}\), where \({\mathbb {P}}\) stands for the set of primes. Particular partition functions are connected with k-ary representations of integers. Let us recall that by a k-ary partition of an integer n we understand the representation of n into powers of k, i.e., the representation of the form

$$\begin{aligned} n=\sum _{i=0}^{u}k^{s_{i}}, \end{aligned}$$
(1)

where \(s_{i}\in \mathbb {N}\) for \(i=0,\ldots , u\) and \(s_{0}\le s_{1}\le \cdots \le s_{u}\). By a colored k-ary representation we understand the k-ary representation, where parts take colors from finite sets.

The basic k-ary partition function is related to the case of \(k=2\). Then, the counting function b(n) of representations of n in the form (1) is called the binary partition function. The sequence \((b(n))_{n\in \mathbb {N}}\) was introduced by Euler, who also noticed the identity

$$\begin{aligned} B(x)=\prod _{n=0}^{\infty }\frac{1}{1-x^{2^{n}}}=\sum _{n=0}^{\infty }b(n)x^{n}. \end{aligned}$$

The series B satisfies the functional equation \((1-x)B(x)=B(x^2)\). In consequence, by comparing the coefficients of \(x^n\) on the both sides of the functional relation, we see that the sequence \((b(n))_{n\in \mathbb {N}}\) satisfies: \(b(0)=b(1)=1\) and

$$\begin{aligned} b(2n)=b(2n-1)+b(n),\quad b(2n+1)=b(2n). \end{aligned}$$

However, it seems that the first non-trivial result concerning the sequence \((b(n))_{n\in \mathbb {N}}\) was obtained by Churchhouse in [4]. In order to state his result, let \(p\in {\mathbb {P}}\) be given and recall that the p-adic valuation of an integer n, denoted by \(\nu _{p}(n)\), is just the highest power of p dividing n, i.e.,

$$\begin{aligned} \nu _{p}(n):={\text {max}}\{k\in \mathbb {N}:\;p^{k}\mid n\} \end{aligned}$$

with the convention that \(\nu _{p}(0)=+\infty \). It is clear that the p-adic valuation satisfies the properties: \(\nu _{p}(n_{1}n_{2})=\nu _{p}(n_{1})+\nu _{p}(n_{2})\) and \(\nu _{p}(n_{1}+n_{2})\ge {\text {min}}\{\nu _{p}(n_{1}),\nu _{p}(n_{2})\}\). Churchhouse proved that the sequence of the 2-adic valuations of \((b(n))_{n\in \mathbb {N}}\) is bounded by 2. More precisely, if \(n\ge 2\), we have \(\nu _{2}(b(n))=2\) if and only if n or \(n-1\) can be written in the form \(4^r(2u+1)\) for some \(r\in \mathbb {N}_{+}\) and \(u\in \mathbb {N}\). In the remaining cases we have \(\nu _{2}(b(n))=1\). One can observe that we can shortly write

$$\begin{aligned} \nu _{2}(b(n))= {\left\{ \begin{array}{ll} \frac{1}{2}|t_{n}-2t_{n-1}+t_{n-2}|&{} \text{ if } \;n\ge 2,\\ 0&{} \text{ if } \;n\in \{0,1\}, \end{array}\right. } \end{aligned}$$
(2)

where \((t_{n})_{n\in \mathbb {N}}\) is the Prouhet–Thue–Morse sequence (the PTM sequence for short). The PTM sequence can be defined in many equivalent ways but the most natural in the context of binary partitions is the one through generating functions. More precisely, we have

$$\begin{aligned} T(x)=\frac{1}{B(x)}=\prod _{n=0}^{\infty } \left( 1-x^{2^{n}}\right) =\sum _{n=0}^{\infty }t_{n}x^{n}. \end{aligned}$$

As an immediate consequence of the functional relation \(T(x)=(1-x)T(x^2)\) we get the recurrence relations

$$\begin{aligned} t_{0}=1, \quad t_{2n}=t_{n}, \quad t_{2n+1}=-t_{n}. \end{aligned}$$

The PTM sequence appears in many different areas of mathematics (and even physics). An interesting introduction to the properties of this sequence can be found in [1]. We will encounter this sequence in the sequel one more time.

In the recent paper [7] Gawron et al. generalized the result of Churchhouse in the following way. Let \(m\in \mathbb {N}_{+}\) and consider the sequence \((b_{m}(n))_{n\in \mathbb {N}}\), where

$$\begin{aligned} B(x)^{m}=\prod _{n=0}^{\infty }\frac{1}{\left( 1-x^{2^{n}}\right) ^{m}} =\sum _{n=0}^{\infty }b_{m}(n)x^{n}. \end{aligned}$$

The sequence \((b_{m}(n))_{n\in \mathbb {N}}\) has a natural combinatorial interpretation. More precisely, the number \(b_m(n)\) counts the number of binary representations (1), where each part has one among m colors. In the cited paper it was proved that the sequence \((\nu _{2}(b_{m}(n)))_{n\in \mathbb {N}}\), with \(m=2^{k}-1, k\in \mathbb {N}_{+}\), is bounded by 2 (and independent of k—a rather unexpected result). This result was further generalized for p-ary colored partitions with \(p\in {\mathbb {P}}_{\ge 3}\) in [11]. Indeed, let \(A_{p,m}(n)\) denote the number of p-ary representations (1) of the number n, where each summand has one among m colors. We proved that for each \(p\in {\mathbb {P}}_{\ge 3}\) and \(s\in \mathbb {N}_{+}\), the p-adic valuation of the number \(A_{p,(p-1)(p^s-1)}(n)\) is equal to 1 for \(n\ge p^s\). We also obtained some results concerning the behavior of the sequence \((\nu _{p}(A_{p,(p-1)(up^s-1)}(n)))_{n\in \mathbb {N}}\) for fixed \(u\in \{2,\ldots ,p-1\}\) and \(p\ge 3\). Let us note that the exponent \((p-1)(p^s-1)\) for \(p=2\) reduces to \(2^s-1\) considered in [7] (in particular \(b_{2^{s}-1}(n)=A_{2,2^s-1}(n)\) for all \(n\in \mathbb {N}\)). This shows striking difference in behavior of the p-adic valuations of \(A_{p,(p-1)(p^s-1)}(n)\) between the case of \(p=2\) and \(p\in {\mathbb {P}}_{\ge 3}\).

In light of the cited results a natural question arises whether there is a p-ary partition type function such that its colored version has a bounded p-adic valuation for each fixed number of colors (not only of particular forms like in the cases considered in [7, 11]). The aim of this paper is to present such a function and obtain exact expression for the corresponding sequence of p-adic valuations.

For \(k\in \mathbb {N}_{\ge 2}\) we consider the power series expansion

$$\begin{aligned} G_{k}(x)=\frac{1}{1-x}\prod _{n=0}^{\infty }\frac{1}{(1-x^{k^{n}})^{k-1}} =\sum _{n=0}^{\infty }S_{k}(n)x^{n}. \end{aligned}$$

Then for \(m\in \mathbb {Z}{\setminus }\{0\}\) we consider the power series

$$\begin{aligned} H_{k,m}(x)=G_{k}(x)^{m}=\frac{1}{(1-x)^{m}}\prod _{n=0}^{\infty } \frac{1}{(1-x^{k^{n}})^{m(k-1)}}=\sum _{n=0}^{\infty }S_{k,m}(n)x^{n}, \end{aligned}$$

and the sequence \((S_{k,m}(n))_{n\in \mathbb {N}}\). Similarly, as in the previous cases the coefficient \(S_{k,m}(n)\) for \(m\in \mathbb {N}_{+}\) has a natural combinatorial interpretation. The number \(S_{k,m}(n)\) counts the number of k-ary representations (1) such that the part equal to 1 takes one among km colors and each part \(>1\) takes one among \((k-1)m\) colors. In this paper we concentrate on the case \(k=p\in {\mathbb {P}}\). As we will see, it is possible to compute the expression for \(\nu _{p}(S_{p,m}(n))\) for each \(p\in {\mathbb {P}}\), \(n\in \mathbb {N}\) and \(m\in \mathbb {Z}\), explicitly. Let us note that in the case \(m<0\) we are working with the sequence with varying signs and it is a non-trivial question whether the number \(S_{p,m}(n)\) can be zero. Unexpectedly, we will show that this is not the case. This non-obvious observation will be a consequence of our main results. We should also mention that as in previous works the cases of \(p=2\) and \(p\in {\mathbb {P}}_{\ge 3}\) are quite different. Thus, we introduce the following definitions with the aim to simplify the notation a bit. More precisely, we write

$$\begin{aligned} c_{m}(n):=S_{2,m}(n),\quad \quad d_{m}(n):=S_{p,m}(n)\quad \text{ for } \text{ fixed }\quad p\in {\mathbb {P}}_{\ge 3}. \end{aligned}$$

Let us note that we have the equality \(c_{1}(n)=b(2n)\) which is a consequence of the equalities

$$\begin{aligned} \sum _{n=0}^{\infty }b(2n)x^{n}=\frac{1}{2}(B(\sqrt{x}) +B(-\sqrt{x}))=\frac{1}{1-x}\prod _{n=0}^{\infty } \frac{1}{1-x^{2^{n}}}=H_{2,1}(x). \end{aligned}$$

We are in position to state the content of the paper in some details.

In Sect. 2 we consider the case \(p=2\) and obtain the closed formula for \(\nu _{2}(c_{m}(n))\) for any given \(m\in \mathbb {Z}\). The formula is stated in Theorem 2.4 and implies that \(\nu _{2}(c_{m}(n))\) is constant for even m and positive n. In the case of odd m the value of \(\nu _{2}(c_{m}(n))\) is equal to 1 or \(\nu _{2}(m+1)+1\), depending on whether \(t_{n}\ne t_{n-1}\) or \(t_{n}=t_{n-1}\), respectively.

The next two sections are devoted to the proof of the equality \(\nu _{p}(d_{m}(n))=\nu _{p}(m)+1\) which holds for \(n\in \mathbb {N}_{+}\) and each \(m\in \mathbb {Z}{\setminus }\{0\}\) (Theorems 3.5 and 3.7). According to our best knowledge our results are the first concerning the exact computation of the p-adic valuations of m colored partitions (with non-rational generating function of course). Moreover, our results can be seen as natural generalizations of Churchhouse result. As a by-product of the employed methods we also get an unexpected fact that the sequence \(\left( \frac{d_{m}(n)}{pm}\ (\mathrm {mod}\ p)\right) _{n\in \mathbb {N}_{+}}\) is independent of m. Thus, a more detailed analysis of this sequence is performed in Sect. 4. The main result of this section is the proof of p-automaticity of the sequence \(\left( \frac{d_{m}(n)}{pm}\ (\mathrm {mod}\ p)\right) _{n\in \mathbb {N}_{+}}\) (Theorem 4.1) and transcendence of the corresponding ordinary generating function (Theorem 4.6).

In Sect. 5 we present the study of the p-adic behavior of the difference \(d_{m}(pn)-d_{m}(n)\). In particular we prove sufficient conditions for the inequality \(\nu _{p}(d_{m}(pn)-d_{m}(n))\ge \nu _{p}(m)+3\) to hold (Theorem 5.5).

Finally, in the last section we ask for a possible generalization of our results, present effects of some numerical computations and formulate some questions, problems and conjectures.

2 The case of \(p=2\)

In order to simplify the notation a bit let us put

$$\begin{aligned} C(x):=G_{2}(x),\quad C_{m}(x):=G_{2}(x)^{m}. \end{aligned}$$

Let us observe that the power series C(x) satisfies the functional relation \((1-x)C(x)=(1+x)C(x^2)\) . In consequence, for \(m\in \mathbb {Z}\) we have the relation

$$\begin{aligned} C_{m}(x)=\left( \frac{1+x}{1-x}\right) ^{m}C_{m}(x^2), \end{aligned}$$

which will be useful in the proof of Lemma 2.2 below. Moreover, in the sequel we will need the following functional property: for \(m_{1}, m_{2}\in \mathbb {Z}\) we have

$$\begin{aligned} C_{m_{1}}(x)C_{m_{2}}(x)=C_{m_{1}+m_{2}}(x). \end{aligned}$$

We start our investigations with a simple lemma which is a consequence of the result of Churchhouse and the product form of the series \(C_{-1}(x)\).

Lemma 2.1

For \(n\in \mathbb {N}_{+}\), we have the following equalities:

$$\begin{aligned} \nu _{2}(c_{1}(n)) =&\frac{1}{2}|t_{n}+3t_{n-1}|,\\ \nu _{2}(c_{-1}(n))=&{\left\{ \begin{array}{ll}\begin{array}{lll} 1 &{} &{} \text{ if } \;t_{n}\ne t_{n-1}, \\ +\infty &{} &{} \text{ if } \;t_{n}=t_{n-1}. \end{array} \end{array}\right. } \end{aligned}$$

Proof

The first equality is an immediate consequence of the equalities \(c_{ 1}(n)=b(2n)\) and (2), and the recurrence relations satisfied by the PTM sequence \((t_{n})_{n\in \mathbb {N}}\), i.e., \(t_{2n}=t_{n}, t_{2n+1}=-t_{n}\).

The second equality comes from the expansion

$$\begin{aligned} C_{-1}(x)=(1-x)\prod _{n=0}^{\infty }(1-x^{2^{n}}) =(1-x)\sum _{n=0}^{\infty }t_{n}x^{n}=1+\sum _{n=1}^{\infty } (t_{n}-t_{n-1})x^{n}. \end{aligned}$$

\(\square \)

In order to compute the 2-adic valuations of the sequence \((c_{\pm 2}(n))_{n\in \mathbb {N}}\) we need the following simple fact:

Lemma 2.2

The sequences \((c_{\pm 2}(n))_{n\in \mathbb {N}}\) satisfy the following recurrence relations: \(c_{\pm 2}(0)=1, c_{\pm 2}(1)=\pm 4\) and for \(n\ge 1\) we have

$$\begin{aligned} c_{\pm 2}(2n) =&\pm 2c_{\pm 2}(2n-1)-c_{\pm 2} (2n-2)+c_{\pm 2}(n)+c_{\pm 2}(n-1),\\ c_{\pm 2}(2n+1)=&\pm 2c_{\pm 2}(2n)-c_{\pm 2}(2n-1)\pm 2c_{\pm 2}(n). \end{aligned}$$

Proof

The recurrence relations for the sequence \((c_{\pm 2}(n))_{n\in \mathbb {N}}\) are immediate consequence of the functional equation \(C_{\pm 2}(x)=\left( \frac{1+x}{1-x}\right) ^{\pm 2}C_{\pm 2}(x^2)\), which can be rewritten in an equivalent form \((1\mp x)^{2}C_{\pm 2}(x)=(1\pm x)^{2}C_{\pm 2}(x^2)\). Comparing now the coefficients on both sides of this relation we get the result. \(\square \)

As a consequence of the recurrence relations for \((c_{\pm 2}(n))_{n\in \mathbb {N}}\) we get:

Corollary 2.3

For \(n\in \mathbb {N}_{+}\) we have \(c_{\pm 2}(n)\equiv 4\ (\mathrm {mod}\ 8)\). In consequence, for \(n\in \mathbb {N}_{+}\) we have \(\nu _{2}(c_{\pm 2}(n))=2\).

Proof

The proof relies on a simple induction. Indeed, we have \(c_{\pm 2}(1)=\pm 4, c_{-2}(2)=4, c_{2}(2)=12\) and thus our statement holds for \(n=1, 2\). Assuming it holds for all integers \(\le n\) and applying the recurrence relations given in Lemma 2.2 we get the result.

The second part is an immediate consequence of the obtained congruence. \(\square \)

Theorem 2.4

Let \(m\in \mathbb {Z}{\setminus }\{0, -1\}\) and consider the sequence \(\mathbf{c}_{m}=(c_{m}(n))_{n\in \mathbb {N}}\). Then \(c_{m}(0)=1\) and for \(n\in \mathbb {N}_{+}\) we have

$$\begin{aligned} \nu _{2}(c_{m}(n))={\left\{ \begin{array}{ll}\begin{array}{lll} \nu _{2}(m)+1 &{} &{} \text{ if } \;m\equiv 0\ (\mathrm {mod}\ 2), \\ 1 &{} &{} \text{ if } \;m\equiv 1\ (\mathrm {mod}\ 2)\;\text{ and }\;t_{n}\ne t_{n-1},\\ \nu _{2}(m+1)+1 &{} &{} \text{ if } \;m\equiv 1\ (\mathrm {mod}\ 2)\;\text{ and }\;t_{n}=t_{n-1}. \end{array} \end{array}\right. } \end{aligned}$$
(3)

Proof

First of all, let us note that our theorem is true for \(m=1, \pm 2\). This is a consequence of Lemma 2.1 and Corollary 2.3. Let \(m\in \mathbb {Z}\) and \(|m|>2\). Because \(c_{m}(0)=1\) and \(c_{m}(1)=2m\), our statement is clearly true for \(n=0,1\). We can assume that \(n\ge 2\).

We start with the case \(m=-3\). From the functional relation \(C_{-3}(x)=C_{-2}(x)C_{-1}(x)\) we immediately get the identity

$$\begin{aligned} c_{-3}(n)=\sum _{i=0}^{n}c_{-1}(i)c_{-2}(n-i)= c_{-2}(n)+t_{n}-t_{n-1}+ \sum _{i=1}^{n-1}(t_{i}-t_{i-1})c_{-2}(n-i). \end{aligned}$$

Let us observe that for \(i\in \{1,\ldots , n-1\}\), from Lemma 2.1 and Corollary 2.3, we obtain the inequality

$$\begin{aligned} \nu _{2}((t_{i}-t_{i-1})c_{-2}(n-i))\ge 3. \end{aligned}$$

In consequence, from Corollary 2.3, we get

$$\begin{aligned} c_{-3}(n)\equiv c_{-2}(n)+t_{n}-t_{n-1}\equiv 4+t_{n}-t_{n-1}\ (\mathrm {mod}\ 8). \end{aligned}$$

It is clear that \(4+t_{n}-t_{n-1}\not \equiv 0\ (\mathrm {mod}\ 8)\). Thus, we get the equality \(\nu _{2}(c_{-3}(n))=\nu _{2}(4+t_{n}-t_{n-1})\) and the result follows for \(m=-3\).

We are ready to prove the general result. At first, we prove it for even numbers m. We proceed by induction on |m|. As we have already proved, our theorem is true for \(m=\pm 2\). Let us assume that it is true for each m satisfying \(|m|<2M\). Let \(|m|= 2M\) and write \(m=4k+r\) for some \(k\in \mathbb {Z}\) and \(r\in \{0,2\}\).

If \(m=4k\), then from the identity \(C_{4k}(x)=C_{2k}(x)^2\) we get the expression

$$\begin{aligned} c_{4k}(n)=2c_{2k}(n)+\sum _{i=1}^{n-1}c_{2k}(i)c_{2k}(n-i). \end{aligned}$$

From the induction hypothesis (notice, that \(|4k|>|2k|\)) we have \(\nu _{2}(c_{2k}(i)c_{2k}(n-i))=2(\nu _{2}(2k)+1)>\nu _{2}(2c_{2k}(n))=\nu _{2}(2k)+2\). In consequence \(\nu _{2}(c_{m}(n))=\nu _{2}(c_{4k}(n))=\nu _{2}(2c_{2k}(n))=\nu _{2}(2k)+2=\nu _{2}(4k)+1\). The obtained equality finishes the proof in the case \(m\equiv 0\ (\mathrm {mod}\ 4)\).

Similarly, if \(m=4k+2\) is positive, we use the identity \(C_{4k+2}(x)=C_{4k}(x)C_{2}(x)\), and get

$$\begin{aligned} c_{4k+2}(n)=c_{2}(n)+c_{4k}(n)+\sum _{i=1}^{n-1}c_{4k}(i)c_{2}(n-i). \end{aligned}$$

Observe that \(|4k+2|>|4k|\). From the equalities \(\nu _{2}(c_{2}(n))=\nu _{2}(2)+1\) and \(\nu _{2}(c_{4k}(n))=\nu _{2}(4k)+1, n\in \mathbb {N}_{+}\), we get \(\nu _{2}(c_{4k}(i)c_{2}(n-i))=\nu _{2}(k)+5\) for each \(i\in \{1,\ldots ,n-1\}\). Thus \(\nu _{2}(c_{2}(n)+c_{4k}(n))=\nu _{2}(c_{2}(n))=2=\nu _{2}(4k+2)+1\).

If \(m=4k+2\) is negative, we use the identity \(C_{4k+2}(x)=C_{4(k+1)}(x)C_{-2}(x)\) and proceed in exactly the same way (here we can use the induction hypothesis because \(|4k+2|>|4(k+1)|\) since \(k<0\)).

Thus we can conclude that the statement is true for all even numbers m. We go to odd ones. We have already shown the theorem for \(m=-1\) and \(m=-3\). Similarly as before, let us write \(m=4k+r\) for some \(k\in \mathbb {Z}\) and \(r\in \{1,3\}\).

If \(m=4k+1>0\), then we use the identity \(C_{4k+1}(x)=C_{4k}(x)C_{1}(x)\) and get

$$\begin{aligned} c_{4k+1}(n)=c_{4k}(n)+c_{1}(n)+\sum _{i=1}^{n-1}c_{4k}(i)c_{1}(n-i). \end{aligned}$$

From the even case we have \(\nu _{2}(c_{4k}(i)c_{1}(n-i))\ge \nu _{2}(4k)+2\ge 4\). Moreover, for \(n\in \mathbb {N}_{+}\) we have \(\nu _{2}(c_{1}(n))\in \{1,2\}\). Thus

$$\begin{aligned} \nu _{2}(c_{4k}(n)+c_{1}(n))=\nu _{2}(c_{1}(n))={\left\{ \begin{array}{ll}\begin{array}{lll} 1 &{} &{} \text{ if } \;t_{n}\ne t_{n-1},\\ 2 &{} &{} \text{ if } \;t_{n}=t_{n-1}. \end{array} \end{array}\right. } \end{aligned}$$

as we claimed.

If \(m=4k+1<0\), we write \(m=4(k+1)-3\) and use the identity \(C_{4k+1}(x)=C_{4(k+1)}(x)C_{-3}(x)\). Next, using the obtained expression for \(\nu _{2}(c_{-3}(n))\) and \(\nu _{2}(c_{4(k+1)}(n))\) and the same reasoning as in the positive case we get the result.

If \(m=4k+3>0\), we use the identity \(C_{4k+3}(x)=C_{4(k+1)}(x)C_{-1}(x)\) which leads us to the expression

$$\begin{aligned} c_{4k+3}(n)=c_{4(k+1)}(n)+c_{-1}(n)+\sum _{i=1}^{n-1}c_{4(k+1)}(i)c_{-1}(n-i). \end{aligned}$$

It is clear that \(\nu _{2}(c_{4(k+1)}(i)c_{-1}(n-i))>\nu _{2}(c_{4(k+1)}(n)+c_{-1}(n))\) for each \(n\in \mathbb {N}_{+}\) and \(i\in \{1,\ldots ,n-1\}\). In consequence, by induction hypothesis

$$\begin{aligned} \nu _{2}(c_{4k+3}(n))&=\nu _{2}(c_{4(k+1)}(n)+c_{-1}(n))\\&={\left\{ \begin{array}{ll}\begin{array}{lll} 1 &{} &{} \text{ if } \;t_{n}\ne t_{n-1},\\ \nu _{2}(c_{4(k+1)}(n)) &{} &{} \text{ if } \;t_{n}=t_{n-1}, \end{array} \end{array}\right. }\\&={\left\{ \begin{array}{ll}\begin{array}{lll} 1 &{} &{} \text{ if } \;t_{n}\ne t_{n-1},\\ \nu _{2}(4k+3+1)+1 &{} &{} \text{ if } \;t_{n}=t_{n-1}. \end{array} \end{array}\right. } \end{aligned}$$

Finally, if \(m=4k+3<0\), then we write \(4k+3=4(k+1)-1\) and employ the identity \(C_{4k+3}(x)=C_{4(k+1)}(x)C_{-1}(x)\). Using the same reasoning as in the previous cases we get the result. \(\square \)

The explicit form of the value of \(\nu _{2}(c_{m}(n))\) for m odd allow us to prove the following.

Corollary 2.5

Let \(m\in \mathbb {Z}\) be odd and \(n\in \mathbb {N}_{+}\). Then \(\nu _{2}(c_{m}(2n)-c_{m}(n))=1\).

Proof

Let us observe that the necessary condition for the inequality \(\nu _{2}(c_{m}(2n)-c_{m}(n))>1\) to hold is the condition

$$\begin{aligned} t_{n}\ne t_{n-1}\Longrightarrow t_{2n}\ne t_{2n-1}\quad \text{ or }\quad t_{n}=t_{n-1}\Longrightarrow t_{2n}=t_{2n-1}. \end{aligned}$$

However, if \(t_{n}\ne t_{n-1}\), then \(t_{n}=-t_{n-1}\) and thus \(t_{2n}-t_{2n-1}=t_{n}+t_{n-1}=0\). Similarly, the equality \(t_{n}=t_{n-1}\) implies that \(t_{n}+t_{n-1}=2t_{n}\) and thus \(t_{2n}-t_{2n-1}=2t_{n}\ne 0\). In other words, if \(\nu _{2}(c_{m}(n))=1\) then \(\nu _{2}(c_{m}(2n))>1\) and vice versa. In consequence we have the equality \(\nu _{2}(c_{m}(2n)-c_{m}(n))=1\) and get the result. \(\square \)

Corollary 2.6

Let \(m\in \mathbb {N}_{+}\) and suppose that \(N\in \mathbb {N}_{+}\) satisfies the condition \(\nu _{2}(N)>\nu _{2}(m+1)+1\). Then the congruence \(c_{m}(n)\equiv 0\pmod {N}\) has no solutions.

Let us observe that the sequence \((\nu _{2}(c_{m}(n)))_{n\in \mathbb {N}}\) (for m odd) can be seen alternatively as a solution of the recurrence relation: \(w_{m}(0)=0, w_{m}(1)=1, w_{m}(2)=\nu _{2}(m+1)+1\) and

$$\begin{aligned} w_{m}(2n+1)=1,\quad w_{m}(4n)=w_{m}(n),\quad w_{m}(4n+2)=\nu _{2}(m+1)+1. \end{aligned}$$

The above recurrence is an immediate consequence of our explicit formula given in Theorem 2.4. We use it in order to show that the sequence \((\nu _{2}(c_{m}(n)))_{n\in \mathbb {N}}\) is 2-automatic. However, before we do this we need to recall the notion of a k-automatic sequence. More precisely, let \(k\in \mathbb {N}_{\ge 2}\) be given. We say that the sequence \({\varepsilon }=(\varepsilon _{n})_{n\in \mathbb {N}}\) is k-automatic if and only if the following set

$$\begin{aligned} K_{k}({\varepsilon })=\{(\varepsilon _{k^{i}n+j})_{n\in \mathbb {N}}:\;i\in \mathbb {N}\;\text{ and }\;0\le j<k^{i}\}, \end{aligned}$$

called the k-kernel of \({\varepsilon }\), is finite. If the k-kernel of the sequence \({\varepsilon }\) is infinite but finitely generated then we say that our sequence is k-regular.

Let us also recall that one of equivalent conditions for automaticity is the following result of Christol:

Lemma 2.7

Let \(p\in {\mathbb {P}}\) and q be a power of p, and \(\mathbf{a}=(a_{n})_{n\in \mathbb {N}}\) be a sequence over \({\mathbb {F}}_{q}\). Then \(\mathbf{a}\) is p-automatic if and only if the formal power series \(\sum _{n=0}^{\infty }a_{n}x^{n}\) is algebraic over \({\mathbb {F}}_{q}(x)\).

The proof can be found in [3] or in recent monograph [1, Theorem 12.2.5].

We are ready to prove that the sequence \((\nu _{2}(c_{m}(n)))_{n\in \mathbb {N}}\) is 2-automatic for each \(m\in \mathbb {Z}{\setminus }\{0,-1\}\).

Theorem 2.8

For each \(m\in \mathbb {Z}{\setminus }\{0,-1\}\) the sequence \(\left( \nu _{2}(c_{m}(n))\right) _{n\in \mathbb {N}_{+}}\) is 2-automatic.

Proof

The result is obvious if m is even, because in this case the sequence is ultimately constant by Theorem 2.4. Let us assume that m is odd and denote \({\tilde{c}}_{m}(n):=\nu _{2}(c_{m}(n))\) for \(n\in \mathbb {N}\), and \({\tilde{C}}_{m}(x):=\sum _{n=0}^{\infty }{\tilde{c}}_{m}(n)x^{n}\). Theorem 2.4 and the remark given above imply the relations:

$$\begin{aligned} \left\{ \begin{array}{l} {\tilde{c}}_{m}(2n+1)= 1, \\ {\tilde{c}}_{m}(4n+2)= \nu _{2}(m+1)+1, \\ {\tilde{c}}_{m}(4n)= {\tilde{c}}_{m}(n). \end{array}\right. \end{aligned}$$

Hence,

$$\begin{aligned} {\tilde{C}}_{m}(x)&= \sum _{n=0}^{\infty }{\tilde{c}}_{m}(4n)x^{4n} +\sum _{n=0}^{\infty }{\tilde{c}}_{m}(4n+2)x^{4n+2} +\sum _{n=0}^{\infty }{\tilde{c}}_{m}(2n+1)x^{2n+1}\\&= \sum _{n=0}^{\infty }{\tilde{c}}_{m}(n)x^{4n}+\left( \nu _{2}(m+1)+1\right) \sum _{n=0}^{\infty }x^{4n+2}+\sum _{n=0}^{\infty }x^{2n+1} \\&= {\tilde{C}}_{m}(x^{4})+\left( \nu _{2}(m+1)+1\right) \frac{x^{2}}{1-x^{4}}+\frac{x}{1-x^{2}}. \end{aligned}$$

Equivalently

$$\begin{aligned} {\tilde{C}}_{m}(x^{4})-{\tilde{C}}_{m}(x)+\frac{x^{3} +\left( \nu _{2}(m+1)+1\right) x^2+1}{1-x^{4}}=0, \end{aligned}$$

so \({\tilde{C}}_{m}(x)\) is algebraic over \(\mathbb {F}_{2}(x)\) and the result follows from Lemma 2.7. \(\square \)

It is worth to note that a sequence is k-automatic if and only if there exists an automaton for it. Roughly speaking, automaton is a procedure that allow us to compute for each \(n\in \mathbb {N}\) the n-th member of a sequence by using only the digits in the (unique) representation of n in the base k. For more precise definition see [2]. We can either use the convention to read the digits of the base-k representation of n from the highest power of k that appear in the representation to the lowest one (that is, from the right to the left), or conversely, that is, from the lowest (i.e., from the 0’th power) to the highest one (that is, from the left to the right). It is known that a given sequence is k-automatic in the first convention if and only if it is k-automatic in the second one, but automatons may be different depending on the convention.

We can present automatons generating the sequence \((\nu _{p}(c_{m}(n)))_{n\in \mathbb {N}_{+}}\) in both conventions. In the case of even m it is very simple. For odd m, they are presented above (Figs. 1 and 2).

Fig. 1
figure 1

Automaton generating \((\nu _{2}(c_{m}(n)))_{n\in \mathbb {N}_{+}}\) for odd m when reading digits of n from the left to the right

Fig. 2
figure 2

Automaton generating \((\nu _{2}(c_{m}(n)))_{n\in \mathbb {N}_{+}}\) for odd m when reading digits of n from the right to the left

Remark 2.9

The second automaton is very similar to the one generating so called period-doubling sequence given by \(e_{n}=\nu _{2}(n+1)\ (\mathrm {mod}\ 2)\) for \(n\in \mathbb {N}\). This sequence was considered for example in [5]. This similarity is not a coincidence, because the period-doubling sequence can be defined also as the sequence \(e_{n}=1-(s_{2}(n)-s_{2}(n-1))\ (\mathrm {mod}\ 2)\), where \(s_{2}(n)\) is the number of 1’s in the unique binary expansion of n. On the other hand, the value of the quantity \(\nu _{2}(c_{m}(n))\) depends on the difference \(t_{n}-t_{n-1}\) and hence, because of the equality \(t_{n}=(-1)^{s_{2}(n)}\), on the difference \(s_{n}-s_{n-1}\).

From the above discussion one can observe that \(e_{n}=1\) if and only if \(t_{n}\ne t_{n-1}\). Thus, Theorem 2.4 for odd m can be rewritten as

$$\begin{aligned} \nu _{2}(c_{m}(n))&= \nu _{2}(n+1)\ (\mathrm {mod}\ 2)+(1-\nu _{2}(n+1)\ (\mathrm {mod}\ 2))(\nu _{2}(m+1)+1) \\&= 1+(1-\nu _{2}(n+1)\ (\mathrm {mod}\ 2))\nu _{2}(m+1) \end{aligned}$$

for all \(n\ge 1\).

Corollary 2.10

If \(m<-1\), then \(c_{m}(n)\ne 0\) for \(n\in \mathbb {N}\).

Proof

From our description of the 2-adic valuation of \(c_{m}(n)\) given in Theorem 2.4, we see that \(\nu _{2}(c_{m}(n))\ne +\infty \) for \(n\in \mathbb {N}\). This is equivalent with the non-vanishing of \(c_{m}(n)\) for \(n\in \mathbb {N}\) and hence the result. \(\square \)

Let us recall that in [7] the sequence \((t_{m}(n))_{n\in \mathbb {N}}\), \(m\in \mathbb {N}_{+}\), was investigated. Here \(t_{m}(n)\) is the Cauchy convolution of m-copies of the PTM sequence, i.e.,

$$\begin{aligned} t_{m}(n)=\sum _{i_{1}+\cdots +i_{m}=n}t_{i_{1}}\ldots t_{i_{m}}. \end{aligned}$$

We characterized the solutions of the equation \(t_{3}(n)=0\) in terms of the expansion of n in base 4. In particular, the equation \(t_{3}(n)=0\) has infinitely many solutions. Moreover, \(t_{m}(n)\ne 0\) for m being power of 2. We also conjectured the non-vanishing of \(t_{m}(n)\) for \(m\ne 3\) but we were unable to prove such a statement. Thus, the above corollary also shows strong difference of the sequences \((t_{m}(n))_{n\in \mathbb {N}}\) and \((c_{-m}(n))_{n\in \mathbb {N}}\) for \(m\in \mathbb {N}_{+}\).

The result obtained in Theorem 2.4 can be also used to prove the following.

Corollary 2.11

Let \(m\in \mathbb {N}_{+}\) and \(U_{m}(n)\) denote the number of binary partitions of n such the part equal to 1 takes one among \(2m+1\) colors and parts \(>1\) take one among m colors. Then \(U_{m}(n)\equiv 1\ (\mathrm {mod}\ 2)\) for \(n\in \mathbb {N}\).

Proof

From the definition of \(U_{m}(n)\) we immediately deduce that \(U_{m}(n)=\sum _{i=0}^{n}c_{m}(i)\). Because \(c_{m}(0)=1\) and from Theorem 2.4 we know that \(c_{m}(n)\equiv 0\ (\mathrm {mod}\ 2)\) for \(n\in \mathbb {N}_{+}\), we get that \(C_{m}(n)\) is odd for \(n\in \mathbb {N}\). \(\square \)

3 The case of \(p\in {\mathbb {P}}_{\ge 3}\)

Let \(p\in {\mathbb {P}}_{\ge 3}\) be fixed. In this section we are interested in the computation of the exact formula for the p-adic valuations of the elements of the sequence \((d_{m}(n))_{n\in \mathbb {N}}\), where

$$\begin{aligned} H_{m,p}(x)=G_{p}(x)^{m}=\frac{1}{(1-x)^{m}}\prod _{n=0}^{\infty } \frac{1}{\left( 1-x^{p^{n}}\right) ^{(p-1)m}} =\sum _{n=0}^{\infty }d_{m}(n)x^{n} \end{aligned}$$

and \(m\in \mathbb {Z}{\setminus }\{0\}\) is fixed. Because p is fixed in the sequel in order to simplify the notation a bit we introduce the quantity:

$$\begin{aligned} H_{m}(x):=H_{p,m}(x). \end{aligned}$$

Let us recall that the number \(d_{m}(n)\) counts the number of p-ary representations of n, where each part \(>1\) can take \((p-1)m\) colors and additionally the part equal to 1 can take pm colors. Moreover, in the sequel we will frequently use the following notation:

$$\begin{aligned} {[A]}={\left\{ \begin{array}{ll}\begin{array}{lll} 1 &{} &{} \text{ if }\; A\;\text{ is } \text{ satisfied }, \\ 0 &{} &{} \text{ otherwise }. \end{array} \end{array}\right. } \end{aligned}$$

where A is given logical formula.

We start with the proof of recurrence relations satisfied by the sequence \((d_{m}(n))_{n\in \mathbb {N}}\) for \(m\in \mathbb {N}_{+}\).

Lemma 3.1

Let \(m\in \mathbb {N}_{+}\). Then \(d_{m}(0)=1\) and for \(n\ge 1\) we have the following recurrence relation:

$$\begin{aligned} d_{m}(n)= & {} -\sum _{i=1}^{{\text {min}}\{pm,n\}}(-1)^{i} \left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(n-i)\\&+\,[p\mid n]\left( \sum _{i=0}^{{\text {min}}\{m,\frac{n}{p}\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m} \left( \frac{n}{p}-i\right) \right) . \end{aligned}$$

Proof

In order to get the result it is enough to note the functional identity

$$\begin{aligned} (1-x)^{pm}H_{m}(x)=(1-x^{p})^{m}H_{m}(x^p). \end{aligned}$$

Indeed, we have the following equalities:

$$\begin{aligned} (1-x)^{pm}H_{m}(x)&=\left( \sum _{i=0}^{pm}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) x^{i}\right) \left( \sum _{n=0}^{\infty }d_{m}(n)x^{n}\right) \\&=\sum _{n=0}^{\infty } \left( \sum _{i=0}^{{\text {min}}\{pm,n\}}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(n-i)\right) x^{n},\\ (1-x^{p})^{m}H_{m}(x^p)&=\left( \sum _{i=0}^{m}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) x^{pi}\right) \left( \sum _{n=0}^{\infty }d_{m}(n)x^{pn}\right) \\&=\sum _{n=0}^{\infty } \left( \sum _{i=0}^{{\text {min}}\{m,n\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i)\right) x^{pn}. \\ \end{aligned}$$

Comparing now the coefficients of \(x^{n}\) on both sides we see that if \(p\not \mid n\), then

$$\begin{aligned} \sum _{i=0}^{{\text {min}}\{pm,n\}}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(n-i)=0 \end{aligned}$$

and if \(p\mid n\), then we have

$$\begin{aligned} \sum _{i=0}^{{\text {min}}\{pm,n\}}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(n-i)=\sum _{i=0}^{{\text {min}}\{m,\frac{n}{p}\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}\left( \frac{n}{p}-i\right) . \end{aligned}$$

Solving for \(d_{m}(n)\) we get the result. \(\square \)

In the sequel we will heavily use the notion of congruences between power series. More precisely, let \(f(x)=\sum _{n=0}^{\infty }a_{n}x^{n}\) and \(g(x)=\sum _{n=0}^{\infty }b_{n}x^{n}\) be formal power series with coefficients in \(\mathbb {Z}\) and \(M\in \mathbb {N}_{\ge 2}\) be given. We say that fg are congruent modulo M if and only if for all n the coefficients of \(x^{n}\) in both series are congruent modulo M. In other words

$$\begin{aligned} f\equiv g\ (\mathrm {mod}\ M)\Longleftrightarrow \forall n\in \mathbb {N}:\;a_{n}\equiv b_{n}\ (\mathrm {mod}\ M). \end{aligned}$$

It is an easy exercise to prove that for any given \(f, F, g, G\in \mathbb {Z}[[x]]\) satisfying \(f\equiv g\ (\mathrm {mod}\ M)\) and \(F\equiv G\ (\mathrm {mod}\ M)\), we have \(f\pm F\equiv g\pm G\ (\mathrm {mod}\ M)\) and \(fF\equiv gG\ (\mathrm {mod}\ M)\). Moreover, if \(f(0), g(0)\in \{-1,1\}\), then the series for 1/f and 1/g have integer coefficients and then \(\frac{1}{f}\equiv \frac{1}{g}\ (\mathrm {mod}\ M)\). Consequently, in this case we have \(f^{k}\equiv g^{k}\ (\mathrm {mod}\ M)\) for all \(k\in \mathbb {Z}\).

Now we are ready to state the following.

Lemma 3.2

Let \(m=p^{\alpha }k\). Then

$$\begin{aligned} d_{m}(n)\equiv 0\ (\mathrm {mod}\ p^{\alpha +1}) \end{aligned}$$

for all \(n\ge 1\).

Proof

From the relation \((1-x)^{p}\equiv 1-x^{p}\ (\mathrm {mod}\ p)\) we get \((1-x)^{p^{\alpha +1}}\equiv (1-x^{p})^{p^{\alpha }}\ (\mathrm {mod}\ p^{\alpha +1})\), and hence,

$$\begin{aligned} (1-x)^{pm}\equiv (1-x^{p})^{m}\ (\mathrm {mod}\ p^{\alpha +1}). \end{aligned}$$

This, together with the equality \((1-x)^{pm}H_{m}(x)=(1-x^{p})^{m}H_{m}(x^{p})\) gives,

$$\begin{aligned} H_{m}(x)\equiv H_{m}(x^{p})\ (\mathrm {mod}\ p^{\alpha +1}). \end{aligned}$$

The above relation simply implies \(d_{m}(n)\equiv 0\ (\mathrm {mod}\ p^{\alpha +1})\) if \(p\not \mid n\), and \(d_{m}(n)\equiv d_{m}(n/p)\ (\mathrm {mod}\ p^{\alpha +1})\) if \(p\mid n\). Hence, if \(n=p^{\beta }l\), then

$$\begin{aligned} d_{m}(n)=d_{m}(p(p^{\beta -1}l))\equiv d_{m}(p^{\beta -1}l)\equiv \cdots \equiv d_{m}(pl)\equiv d_{m}(l)\equiv 0\ (\mathrm {mod}\ p^{\alpha +1}). \end{aligned}$$

Therefore, the only coefficient of the series \(H_{m}(x)\) not divisible by \(p^{\alpha +1}\) is \(d_{m}(0)=1\). \(\square \)

Lemma 3.3

Let \(m=p^{\alpha }k\). Then

$$\begin{aligned} d_{m}(pn)\equiv d_{m}(n)\ (\mathrm {mod}\ p^{\alpha +2}) \end{aligned}$$

for all \(n\ge 1\).

Proof

We use the induction argument. For \(n=1\) we have by Lemma 3.1:

$$\begin{aligned} d_{m}(p)&= -\sum _{i=1}^{p}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(p-i) +\sum _{i=0}^{1}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(1-i) \\&= -\sum _{i=1}^{p}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(p-i)+d_{m}(1)-md_{m}(0). \end{aligned}$$

Observe that if \(p\not \mid i\) then \(p\mid \left( {\begin{array}{c}pm\\ i\end{array}}\right) \). From Lemma 3.2 we also have \(p^{\alpha +1}\mid d_{m}(p-i)\) for \(i=1,\ldots ,p-1\). Hence, \(\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(p-i)\equiv 0\ (\mathrm {mod}\ p^{\alpha +2})\) for \(i=1,\ldots ,p-1\), so

$$\begin{aligned} d_{m}(p)&\equiv \left( {\begin{array}{c}pm\\ p\end{array}}\right) d_{m}(0)+d_{m}(1)-md_{m}(0)\equiv md_{m}(0)+d_{m}(1)-md_{m}(0)\\&\equiv d_{m}(1)\ (\mathrm {mod}\ p^{\alpha +2}). \end{aligned}$$

Let us assume that the statement is true for all numbers less than some number n. We want to prove it for n. Lemma 3.1 implies

$$\begin{aligned} d_{m}(pn)&= -\sum _{i=1}^{\min \{pm,pn\}}(-1)^{i} \left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(pn-i)+\sum _{i=0}^{\min \{m,n\}}(-1)^{i} \left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i) \\&\equiv -\sum _{i=1}^{\min \{m,n\}}(-1)^{pi} \left( {\begin{array}{c}pm\\ pi\end{array}}\right) d_{m}(pn-pi)+\sum _{i=0}^{\min \{m,n\}}(-1)^{i} \left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i) \\&= -\sum _{i=1}^{\min \{m,n\}}(-1)^{i} \left( {\begin{array}{c}pm\\ pi\end{array}}\right) d_{m}(p(n-i))+\sum _{i=0}^{\min \{m,n\}}(-1)^{i} \left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i) \\&\equiv -\sum _{i=1}^{\min \{m,n\}}(-1)^{i} \left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i)+\sum _{i=0}^{\min \{m,n\}}(-1)^{i} \left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i) \\&= d_{m}(n)\ (\mathrm {mod}\ p^{\alpha +2}). \end{aligned}$$

In the above computations we used the induction hypothesis, Lemma 3.2 and the congruence \(\left( {\begin{array}{c}pm\\ pi\end{array}}\right) \equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \ (\mathrm {mod}\ p)\) which is a consequence of Lucas theorem. The result follows. \(\square \)

Lemma 3.4

Let \(m=p^{\alpha }\). Then

$$\begin{aligned} d_{m}(n)\equiv \left\{ \begin{array}{ll} (-1)^{n+1}\left( {\begin{array}{c}pm\\ n\end{array}}\right) \ (\mathrm {mod}\ p^{\alpha +2})&{} \text {if } n\le pm, \\ d_{m}(n-pm)\ (\mathrm {mod}\ p^{\alpha +2}) &{} \text {if } n>pm \end{array}\right. \end{aligned}$$

for all \(n\ge 1\) such that \(p\not \mid n\).

Proof

Let \(n\in \mathbb {N}_{+}\) and assume that \(p\not \mid n\). Then Lemma 3.1 implies the equality

$$\begin{aligned} d_{m}(n)=\sum _{i=1}^{\min \{pm,n\}}(-1)^{i+1}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(n-i). \end{aligned}$$

If \(p\not \mid i\) then \(p|\left( {\begin{array}{c}pm\\ i\end{array}}\right) \), and by Lemma 3.2 we get the divisibility property \(p^{\alpha +1}|d_{m,p}(n-i)\) which holds for \(n>i\) . Therefore, if \(n<pm\), then the only term in the above sum that may not be divisible by \(p^{\alpha +2}\) is the one corresponding to \(i=n\), i.e., \((-1)^{n+1}\left( {\begin{array}{c}pm\\ n\end{array}}\right) d_{m,p}(0)=(-1)^{n+1}\left( {\begin{array}{c}pm\\ n\end{array}}\right) \). Similarly, if \(n>pm\), then the only such term can be the one corresponding to \(i=pm\), i.e., \((-1)^{pm+1}\left( {\begin{array}{c}pm\\ pm\end{array}}\right) d_{m}(n-pm)=d_{m}(n-pm)\). \(\square \)

Now we are ready to prove the following general result concerning the expression of \(\nu _{p}(d_{m}(n))\) for \(m\in \mathbb {N}_{+}\).

Theorem 3.5

Let \(p\in {\mathbb {P}}_{\ge 3}\) and \(m\in \mathbb {N}\). Let \(n\in \mathbb {N}_{\ge 1}\) and \(n=n_{s}p^{s}+\cdots +n_{t}p^{t}\) be (the unique) representation of n in base p. Here \(s\le t\) and \(n_{s}\ne 0\). Then

$$\begin{aligned} d_{m}(n)\equiv pm\left( n_{s}^{-1}\ (\mathrm {mod}\ p)\right) \ (\mathrm {mod}\ p^{\nu _{p}(m)+2}). \end{aligned}$$

In particular,

$$\begin{aligned} \nu _{p}(d_{m}(n))={\left\{ \begin{array}{ll}\begin{array}{lll} 0 &{} &{} \text{ if } \;n=0, \\ \nu _{p}(m)+1 &{} &{} \text{ if } \; n\ge 1. \end{array} \end{array}\right. } \end{aligned}$$

Proof

At the beginning observe that for each m we have \(d_{m}(0)=1\), so \(\nu _{p}(d_{m}(0))=0\).

Let us assume that \(n\ge 1\) and \(m=p^{\alpha }\) for some \(\alpha \ge 0\). By Lemma 3.2 it is reasonable to consider the sequence \(\mathbf{a}_{\alpha }=(a_{\alpha }(n))_{n\in \mathbb {N}_{+}}\) of elements of \(\mathbb {Z}/p\mathbb {Z}\), where

$$\begin{aligned} a_{\alpha }(n):=\frac{d_{m}(n)}{p^{\alpha +1}}\ (\mathrm {mod}\ p). \end{aligned}$$

Lemmas 3.3 and 3.4 imply the following recurrence relations:

$$\begin{aligned} \left\{ \begin{array}{ll} a_{\alpha }(n)=\frac{(-1)^{n+1}}{p^{\alpha +1}}\left( {\begin{array}{c}p^{\alpha +1}\\ n\end{array}}\right) \ (\mathrm {mod}\ p) &{} \text {if } n<p^{\alpha +1} \text { and } p\not \mid n, \\ a_{\alpha }(n)=a_{\alpha }(n-p^{\alpha +1}) &{} \text {if } n>p^{\alpha +1} \text { and } p\not \mid n, \\ a_{\alpha }(pn)=a_{\alpha }(n). \end{array}\right. \end{aligned}$$

Observe that if \(n<p^{\alpha +1}\) and \(p\not \mid n\) then,

$$\begin{aligned} \frac{(-1)^{n+1}}{p^{\alpha +1}}\left( {\begin{array}{c}p^{\alpha +1}\\ n\end{array}}\right)&= (-1)^{n+1}\frac{(p^{\alpha +1}-1)(p^{\alpha +1}-2)\cdot \ldots \cdot (p^{\alpha +1}-n+1)}{n!} \\&\equiv (-1)^{n+1}\frac{(-1)(-2)\cdot \ldots \cdot (-n+1)}{n!}\\&=(-1)^{n+1}\frac{(-1)^{n-1}(n-1)!}{n!}=\frac{1}{n}\ (\mathrm {mod}\ p). \end{aligned}$$

Thus \(a_{\alpha }(n)=\frac{1}{n}\ (\mathrm {mod}\ p)\) for \(n<p^{\alpha +1}\) such that \(p\not \mid n\). If n is arbitrary, then recurrence relations for \(a_{\alpha }(n)\) imply

$$\begin{aligned} a_{\alpha }(n)=a_{\alpha }\left( \frac{n}{p^{\nu _{p}(n)}}\right) =a_{\alpha }\left( \frac{n}{p^{\nu _{p}(n)}}\ (\mathrm {mod}\ p^{\alpha +1})\right) =\frac{1}{\frac{n}{p^{\nu _{p}(n)}}\ (\mathrm {mod}\ p^{\alpha +1})}\ (\mathrm {mod}\ p). \end{aligned}$$

Write \(n=n_{s}p^{s}+\cdots +n_{t}p^{t}\), \(s\le t\), \(n_{s}>0\). Then

$$\begin{aligned} \frac{n}{p^{\nu _{p}(n)}}\ (\mathrm {mod}\ p^{\alpha +1})=n_{s}+\cdots +n_{s+\alpha }p^{\alpha }=:N \end{aligned}$$

(we define \(n_{i}=0\) for \(i>t\) if required). Observe that for \(M=n_{s}^{-1}\ (\mathrm {mod}\ p)\) we have \(MN\equiv 1\ (\mathrm {mod}\ p)\). Hence, \(a_{\alpha }(n)=n_{s}^{-1}\ (\mathrm {mod}\ p)\).

From the definition we get

$$\begin{aligned} d_{m}(n)\equiv p^{\alpha +1}a_{\alpha }(n)=pm\left( n_{s}^{-1}\ (\mathrm {mod}\ p)\right) \ (\mathrm {mod}\ p^{\alpha +2}). \end{aligned}$$

Hence the result is true if m is a power of p or \(m=1\).

If \(m=p^{\alpha }k\), where \(k\in \mathbb {N}_{+}\) and \(p\not \mid k\), then

$$\begin{aligned} H_{m}(x)=\left( H_{p^{\alpha }}(x)\right) ^{k}, \end{aligned}$$

so

$$\begin{aligned} d_{m}(n)=\sum _{a_{1}+\cdots +a_{k}=n}d_{p^{\alpha }}(a_{1})\cdot \ldots \cdot d_{p^{\alpha }}(a_{k}). \end{aligned}$$

We note that, if at least two numbers among \(a_{1},\ldots ,a_{k}\) are non–zero, then by Lemma 3.2 we get \(d_{p^{\alpha }}(a_{1})\cdot \ldots \cdot d_{p^{\alpha }}(a_{k})\equiv 0\ (\mathrm {mod}\ p^{\alpha +2})\). Hence, the expression \(d_{p^{\alpha }}(a_{1})\cdot \ldots \cdot d_{p^{\alpha }}(a_{k})\) may not be divisible by \(p^{\alpha +2}\) only if \(a_{j}=n\) for some j and \(a_{i}=0\) for all \(i\ne j\). Thus

$$\begin{aligned} d_{m}(n)\equiv kd_{p^{\alpha }}(n)\equiv \frac{kp^{\alpha +1}}{n_{s}}=pm\left( n_{s}^{-1}\ (\mathrm {mod}\ p)\right) \ (\mathrm {mod}\ p^{\alpha +2}), \end{aligned}$$

and our result follows. \(\square \)

One can ask, whether it is possible to give a theorem similar to Theorem 3.5 but for negative integers m? In order to give an answer, let us introduce the sequence \((D_{p}(n))_{n=1}^{\infty }\) defined as

$$\begin{aligned} \Delta _{p}(x):=\prod _{n=0}^{\infty }(1-x^{p^{n}})^{p-1} =\sum _{n=0}^{\infty }D_{p}(n)x^{n}. \end{aligned}$$

Observe that

$$\begin{aligned} H_{-1}(x)=(1-x)\Delta _{p}(x)=1+\sum _{n=1}^{\infty } \left( D_{p}(n)-D_{p}(n-1)\right) x^{n}. \end{aligned}$$

Therefore, \(d_{-1}(n)=D_{p}(n)-D_{p}(n-1)\) for \(n\ge 1\), and \(d_{-1}(0)=1\). From [11, Lemma 2.3] we get the equality

$$\begin{aligned} \nu _{p}(d_{-1}(n))=\left\{ \begin{array}{ll} 0 &{} \text { if } n=0, \\ 1 &{} \text { if } n\ge 1. \end{array}\right. \end{aligned}$$

We will also need the following simple fact.

Lemma 3.6

Let \(i\in \mathbb {N}_{\ge 2}\) and \(p\in {\mathbb {P}}_{\ge 3}\). Then

$$\begin{aligned} i\ge \nu _{p}(i)+2. \end{aligned}$$

Proof

Let \(i\in \mathbb {N}_{\ge 1}\). We always have \(i>\nu _{p}(i)\), i.e., \(i\ge \nu _{p}(i)+1\). Thus if \(i<\nu _{p}(i)+2\), then \(i=\nu _{p}(i)+1\). From the Bernoulli’s inequality we get

$$\begin{aligned} i\ge p^{\nu _{p}(i)}\ge 2^{\nu _{p}(i)}=(1+1)^{\nu _{p}(i)}\ge 1+\nu _{p}(i)=i. \end{aligned}$$

Hence, \(p^{\nu _{p}(i)}=2^{\nu _{p}(i)}\), so \(\nu _{p}(i)=0\) and thus \(i=1\). \(\square \)

We are ready to prove the following analog of Theorem 3.5.

Theorem 3.7

Let \(m\in \mathbb {N}_{\ge 1}\). Then

$$\begin{aligned} d_{-m}(n)\equiv md_{-1}(n)\ (\mathrm {mod}\ p^{\nu _{p}(m) +2}). \end{aligned}$$

In particular,

$$\begin{aligned} \nu _{p}(d_{-m}(n))=\left\{ \begin{array}{ll} 0 &{} \text { if } n=0, \\ \nu _{p}(m)+1&{} \text { if } n\ge 1. \end{array}\right. \end{aligned}$$

Proof

First, we prove the result for \(m=p^{\alpha }\). Observe that

$$\begin{aligned} H_{-p^{\alpha }}(x)&= \left( H_{-1}(x)\right) ^{p^{\alpha }}=\sum _{n=0}^{\infty } \left( \sum _{j_{1}+\cdots +{j_{p^{\alpha }}}=n}d_{-1}(j_{1}) \cdot \ldots \cdot d_{-1}(j_{p^{\alpha }})\right) x^{n} \\&= 1+ \sum _{n=1}^{\infty }\left[ \sum _{i=1}^{p^{\alpha }} \left( \left( {\begin{array}{c}p^{\alpha }\\ i\end{array}}\right) \sum _{\begin{array}{c} j_{1}+\cdots +j_{i}=n \\ j_{1},\ldots ,j_{i}\ge 1 \end{array}}d_{-1}(j_{1})\cdot \ldots \cdot d_{-1}(j_{i})\right) \right] x^{n}, \end{aligned}$$

because \(d_{-1}(0)=1\). From Lemma 3.6 we have for \(i\ge 2\):

$$\begin{aligned} \nu _{p}\left( \left( {\begin{array}{c}p^{\alpha }\\ i\end{array}}\right) \sum _{\begin{array}{c} j_{1}+\cdots +j_{i}=n \\ j_{1},\ldots ,j_{i}\ge 1 \end{array}}d_{-1}(j_{1})\cdot \ldots \cdot d_{-1}(j_{i})\right) \ge \alpha -\nu _{p}(i)+i\ge \alpha +2. \end{aligned}$$

Therefore,

$$\begin{aligned} H_{-p^{\alpha }}(x)\equiv&1+ \sum _{n=1}^{\infty }p^{\alpha }d_{-1}(n)x^{n}\ (\mathrm {mod}\ p^{\alpha +2}). \end{aligned}$$

Hence, the result is true when m is a power of p or \(m=1\). If \(m=p^{\alpha }k\), where \(p\not \mid k\), then similarly as in the proof of Theorem 3.5 we get

$$\begin{aligned} H_{-m}(x)&= \left( H_{-p^{\alpha }}(x)\right) ^{k}=\sum _{n=0}^{\infty } \left( \sum _{j_{1}+\cdots +j_{k}=n}d_{-p^{\alpha }}(j_{1}) \cdot \ldots \cdot d_{-p^{\alpha }}(j_{k})\right) x^{n} \\&\equiv \sum _{n=0}^{\infty }kd_{-p^{\alpha }}(n)x^{n}\equiv \sum _{n=0}^{\infty }kp^{\alpha }d_{-1}(n)x^{n}= \sum _{n=0}^{\infty }md_{-1}(n)x^{n} \ (\mathrm {mod}\ p^{\alpha +2}). \end{aligned}$$

The result follows. \(\square \)

Corollary 3.8

If \(m\le -1\), then \(d_{m}(n)\ne 0\) for \(n\in \mathbb {N}\).

Proof

From our description of the p-adic valuation of \(d_{m}(n)\) given in Theorem 3.7, we see that \(\nu _{p}(d_{m}(n))\ne +\infty \) for \(n\in \mathbb {N}\). This is equivalent with the non-vanishing of \(d_{m}(n)\) for \(n\in \mathbb {N}\) and hence the result. \(\square \)

As a very surprising corollary from Theorems 3.5 and 3.7 we get the next fact.

Corollary 3.9

If \(p\in {\mathbb {P}}_{\ge 3}\) and \(m\in \mathbb {Z}{\setminus }\{0\}\), then the sequence \(\left( \frac{d_{m}(n)}{pm}\ (\mathrm {mod}\ p)\right) _{n\in \mathbb {N}_{+}}\) depends only on the sign of m.

4 On p-automaticity of the sequence \(\left( \frac{d_{m}(n)}{pm}\ (\mathrm {mod}\ p)\right) _{n\in \pmb {\mathbb {N}}_{+}}\)

For \(p\in {\mathbb {P}}_{\ge 3}\) and \(n\in \mathbb {N}_{+}\), let us denote \(y_{p}(n):=\frac{d_{m}(n)}{pm}\ (\mathrm {mod}\ p)\) if \(m>0\), and \(z_{p}(n):=\left( -\frac{d_{m}(n)}{pm}\right) {\ (\mathrm {mod}\ p)}\) if \(m<0\). In this section we will study the sequences \((y_{p}(n))_{n\in \mathbb {N}_{+}}, (z_{p}(n))_{n\in \mathbb {N}_{+}}\) more closely. In particular we prove p-automaticity of our sequences.

Let

$$\begin{aligned} Y_{p}(x)&= \sum _{n=0}^{\infty }y_{p}(n+1)x^{n}, \\ Z_{p}(x)&= \sum _{n=0}^{\infty }z_{p}(n+1)x^{n}, \end{aligned}$$

i.e., \(Y_{p}\) and \(Z_{p}\) are the generating functions of the sequences \((y_{p}(n))_{n\in \mathbb {N}_{+}}\) and \((z_{p}(n))_{n\in \mathbb {N}_{+}}\), respectively.

Now we are ready to state the main result of this section.

Theorem 4.1

Both sequences, \((y_{p}(n))_{n\in \mathbb {N}_{+}}\) and \((z_{p}(n))_{n\in \mathbb {N}_{+}}\), are p-automatic.

Proof

By Lemma 2.7 it is enough to show that \(Y_{p}\) and \(Z_{p}\) are both algebraic over \({\mathbb {F}}_{p}(x)\). First we consider the series \(Y_{p}\). Let us denote

$$\begin{aligned} W_{p}(x):=\sum _{n=1}^{p-1}(n^{-1}\ (\mathrm {mod}\ p))x^{n-1}. \end{aligned}$$

In the proof of Theorem 3.5 it was shown, that the sequence \((y_{p}(n))_{n=1}^{\infty }\) satisfies the following recurrence relations:

$$\begin{aligned} \left\{ \begin{array}{ll} y_{p}(n)=n^{-1}\ (\mathrm {mod}\ p) &{} \text { if } 1\le n\le p-1, \\ y_{p}(n)=y_{p}(n\ (\mathrm {mod}\ p)) &{} \text { if } p\not \mid n, \\ y_{p}(pn)=y_{p}(n). \end{array}\right. \end{aligned}$$

Therefore,

$$\begin{aligned} Y_{p}(x)&= \sum _{n=1}^{\infty }y_{p}(pn)x^{pn-1}+\sum _{n=0}^{\infty } \left( y_{p}(1)+y_{p}(2)x+\ldots y_{p}(p-1)x^{p-2}\right) x^{pn} \\&= x^{p-1}\sum _{n=1}^{\infty }y_{p}(n)x^{p(n-1)}+W_{p}(x) \sum _{n=0}^{\infty }x^{pn} \\&= x^{p-1}\sum _{n=0}^{\infty }y_{p}(n+1)x^{pn}+\frac{W_{p}(x)}{1-x^{p}} \\&= x^{p-1}Y_{p}(x^{p})+\frac{W_{p}(x)}{1-x^{p}}. \end{aligned}$$

Equivalently,

$$\begin{aligned} x^{p-1}Y_{p}(x)^{p}-Y_{p}(x)+\frac{W_{p}(x)}{1-x^{p}}=0, \end{aligned}$$
(4)

so \(Y_{p}\) is indeed algebraic over \({\mathbb {F}}_{p}(x)\).

For the proof of the case of the sequence \(Z_{p}\), notice the following relations:

$$\begin{aligned} \Delta _{p}(x)&= \prod _{n=0}^{\infty }\left( 1-x^{p^{n}}\right) ^{p-1} =(1-x)^{p-1}\Delta _{p}(x^{p}), \\ H_{-1}(x)&= (1-x)\Delta _{p}(x)=(1-x)^{p}\Delta _{p}(x^{p}) =\frac{(1-x)^{p}}{1-x^{p}}H_{-1}(x^{p}), \\ Z_{p}(x)&\equiv \frac{1}{px}\left( H_{-1}(x)-1\right) \ (\mathrm {mod}\ p). \end{aligned}$$

The last congruence follows from the fact that \(z_{p}(n)\equiv \frac{d_{-1}(n)}{p}\ (\mathrm {mod}\ p)\). Thus (we consider the equalities below as equalities over \({\mathbb {F}}_{p}\), i.e., modulo p)

$$\begin{aligned} Z_{p}(x)&= \frac{1}{px}\left( H_{-1}(x)-1\right) =\frac{1}{px} \left( \frac{(1-x)^{p}}{1-x^{p}}H_{-1}(x^{p})-1\right) \\&= \frac{1}{px}\left( \frac{(1-x)^{p}}{1-x^{p}} \left( H_{-1}(x^{p})-1\right) +\frac{(1-x)^{p}}{1-x^{p}}-1\right) \\&= x^{p-1}\frac{(1-x)^{p}}{1-x^{p}}\frac{1}{px^{p}} \left( H_{-1}(x^{p})-1\right) +\frac{1}{px} \frac{(1-x)^{p}-(1-x^{p})}{1-x^{p}} \\&= x^{p-1}\frac{(1-x)^{p}}{1-x^{p}}Z_{p}(x^{p}) +\frac{1}{1-x^{p}}\left( \sum _{n=1}^{p-1}(-1)^{n}\frac{1}{p} \left( {\begin{array}{c}p\\ n\end{array}}\right) x^{n-1}\right) \\&= x^{p-1}Z_{p}(x^{p})-\frac{W_{p}(x)}{1-x^{p}}, \end{aligned}$$

because for each \(1\le n\le p-1\):

$$\begin{aligned} (-1)^{n}\frac{1}{p}\left( {\begin{array}{c}p\\ n\end{array}}\right)&=(-1)^{n}\frac{(p-1)\ldots (p-n+1)}{n!}\equiv (-1)^{n}\frac{(-1)^{n-1}(n-1)!}{n!}\\&=-\frac{1}{n}\ (\mathrm {mod}\ p). \end{aligned}$$

We can write the equation for \(Z_{p}\) in an equivalent form as

$$\begin{aligned} x^{p-1}Z_{p}(x)^{p}-Z_{p}(x)-\frac{W_{p}(x)}{1-x^{p}}=0, \end{aligned}$$
(5)

so \(Z_{p}\) is also algebraic over \({\mathbb {F}}_{p}(x)\). \(\square \)

The explicit form of the equations satisfied by \(Y_{p}\) and \(Z_{p}\) allow us to show the strong relation between sequences \((y_{p}(n))_{n\in \mathbb {N}_{+}}\) and \((z_{p}(n))_{n\in \mathbb {N}_{+}}\).

Corollary 4.2

If \(p\in {\mathbb {P}}_{\ge 3}\) and \(n\in \mathbb {N}_{\ge 1}\), then

$$\begin{aligned} y_{p}(n)+z_{p}(n)\equiv 0\ (\mathrm {mod}\ p). \end{aligned}$$

Proof

Summing Eqs. (4) and (5) we get

$$\begin{aligned} \left( Y_{p}(x)+Z_{p}(x)\right) \left( x^{p-1}\left( Y_{p}(x)+Z_{p}(x)\right) ^{p-1}-1\right) \equiv 0\ (\mathrm {mod}\ p). \end{aligned}$$

Because the 0th term in the second factor is not divisible by p we need to have

$$\begin{aligned} Y_{p}(x)+Z_{p}(x)\equiv 0\ (\mathrm {mod}\ p), \end{aligned}$$

and this is equivalent to the statement. \(\square \)

In the case of sequences \((y_{p}(n))_{n\in \mathbb {N}_{+}}\) and \((z_{p}(n))_{n\in \mathbb {N}_{+}}\) we can write the automatons down in both conventions (recall the discussion at the end of Sect. 2). Now we show them for the first of these sequences. In the case of the second one, it is enough to switch \(n^{-1}\) into \(-n^{-1}\) for all \(n=1, \ldots , p-1\). The automaton generating \((y_{p}(n))_{n\in \mathbb {N}_{+}}\) when we read digits from the left to the right is presented below (Fig. 3).

Fig. 3
figure 3

Automaton generating \((y_{p}(n))_{n\in \mathbb {N}}\) when reading digits of n from the left to the right

Fig. 4
figure 4

Automaton generating \((y_{p}(n))_{n\in \mathbb {N}}\) when reading digits of n from the right to the left

On the other side, if we read the digits in the opposite direction we present the corresponding automaton generating \((y_{p}(n))_{n\in \mathbb {N}}\) below (Fig. 4).

More precisely, in the second automaton each arrow with number 0 forms a loop, and each arrow with a number \(n\in \{1,\ldots ,p-1\}\) goes to the state with \(n^{-1}\).

Let us note that in the case \(p\ge 3\) the sequence \((\nu _{p}(d_{m}(n)))_{n\in \mathbb {N}}\) is p-automatic, which is an immediate consequence of the fact that it is ultimately constant.

Corollary 4.2 can be used to find a relation between numbers \(d_{m}(n)\) and \(d_{-m}(n)\), and generalize some results obtained previously only for positive m. We have the following.

Theorem 4.3

For each \(p\in {\mathbb {P}}_{\ge 3}\), \(m\in \mathbb {N}_{\ge 1}\) and \(n\in \mathbb {N}\) we have

$$\begin{aligned} d_{-m}(n)\equiv -d_{m}(n)\ (\mathrm {mod}\ p^{\nu _{p}(m)+2}). \end{aligned}$$

In particular,

$$\begin{aligned} d_{-m}(pn)\equiv d_{-m}(n)\ (\mathrm {mod}\ p^{\nu _{p}(m)+2}). \end{aligned}$$

Proof

The first part follows from Theorems 3.5 and 3.7 , and Corollary 4.2. Indeed,

$$\begin{aligned} d_{-m}(n)\equiv pmz_{p}(n)\equiv -pmy_{p}(n)\equiv -d_{m}(n)\ (\mathrm {mod}\ p^{\nu _{p}(m)+2}). \end{aligned}$$

The second part is now an immediate consequence of Lemma 3.3. \(\square \)

We group the fact above, Theorems 3.5 and 3.7 , and Corollary 3.9 and simply get the following general result.

Corollary 4.4

Let \(p\in {\mathbb {P}}_{\ge 3}\) and \(m\in \mathbb {Z}{\setminus }\{0\}\). Let \(n\in \mathbb {N}_{\ge 1}\) and \(n=n_{s}p^{s}+\cdots +n_{t}p^{t}\) be its base-p representation, where \(s\le t\) and \(n_{s}\ne 0\). Then

$$\begin{aligned} d_{m}(n)\equiv pm\left( n_{s}^{-1}\ (\mathrm {mod}\ p)\right) \ (\mathrm {mod}\ p^{\nu _{p}(m)+2}). \end{aligned}$$

In particular,

$$\begin{aligned} \nu _{p}(d_{m}(n))=\left\{ \begin{array}{ll} 0 &{} \text { if } n=0, \\ \nu _{p}(m)+1 &{} \text { if } n\ge 1, \end{array} \right. \end{aligned}$$

and the sequence \(\left( \frac{d_{m}(n)}{pm}\ (\mathrm {mod}\ p)\right) _{n=1}^{\infty }\) does not depend on m.

We can apply Corollary 4.4 to the problem that was considered in [11]. Let us define for \(p\in {\mathbb {P}}_{\ge 3}\), \(m\in \mathbb {N}_{\ge 1}\) a sequence \((A_{p,m}(n))_{n\in \mathbb {N}}\) as

$$\begin{aligned} \prod _{n=0}^{\infty }\frac{1}{(1-x^{p^{n}})^{m}} =\sum _{n=0}^{\infty }A_{p,m}(n)x^{n}. \end{aligned}$$

The number \(A_{p,m}(n)\) counts the number of p-ary representations of n such that each part takes one among m colors. The sequence \((A_{p,m}(n))_{n\in \mathbb {N}}\) was thoroughly studied in [11]. One of main results of the cited paper states that for each \(\alpha \in \mathbb {N}_{\ge 1}\) and \(n\ge p^{\alpha }\) the following equality holds:

$$\begin{aligned} \nu _{p}\left( A_{p,(p-1)(p^{\alpha }-1)}(n)\right) =1. \end{aligned}$$

Using our previous findings we are able to improve the above equality to the following.

Theorem 4.5

Let \(p\in {\mathbb {P}}_{\ge 3}\), \(\alpha \in \mathbb {N}_{\ge 1}\) and \(n\ge p^{\alpha }\). Let \(n=\sum _{j=s}^{t}n_{j}p^{j}\), where \(s\le t\) and \(n_{s}\ne 0\), be the base-p representation of n. Then

$$\begin{aligned} A_{p,(p-1)(p^{\alpha }-1)}(n)\equiv -p(n_{s}^{-1}\ (\mathrm {mod}\ p))\ (\mathrm {mod}\ p^{2}). \end{aligned}$$

Proof

The relation on the very end of the proof of Theorem 3.1 from [11] implies that

$$\begin{aligned} A_{p,(p-1)(p^{\alpha }-1)}(n)\equiv \left( D_{p}(n)-D_{p}(n-1)\right) \prod _{j=0}^{\alpha -1}(-1)^{n_{j}}\left( {\begin{array}{c}p-1\\ n_{j}\end{array}}\right) \ (\mathrm {mod}\ p^{2}) \end{aligned}$$

(we assume that \(n_{j}=0\) for \(j<s\)). Corollary 4.4 gives

$$\begin{aligned} A_{p,(p-1)(p^{\alpha }-1)}(n)&\equiv d_{-1}(n)\prod _{j=0}^{\alpha -1}(-1)^{n_{j}}\left( {\begin{array}{c}p-1\\ n_{j}\end{array}}\right) \\&\equiv -p(n_{s}^{-1}\ (\mathrm {mod}\ p))\prod _{j=0}^{\alpha -1}(-1)^{n_{j}}\left( {\begin{array}{c}p-1\\ n_{j}\end{array}}\right) \ (\mathrm {mod}\ p^{2}). \end{aligned}$$

For the end of the proof it is enough to observe that for each \(j\in \{0,\ldots ,\alpha -1\}\):

$$\begin{aligned} (-1)^{n_{j}}\left( {\begin{array}{c}p-1\\ n_{j}\end{array}}\right) =&(-1)^{n_{j}}\frac{(p-1)\ldots (p-n_{j})}{n_{j}!}\equiv (-1)^{n_{j}}\frac{(-1)^{n_{j}}n_{j}!}{n_{j}!}=1 \ (\mathrm {mod}\ p). \end{aligned}$$

\(\square \)

We finish this section with the following

Theorem 4.6

Let us consider the sequences \((y_{p}(n))_{n\in \mathbb {N}_{+}}\), \((z_{p}(n))_{n\in \mathbb {N}_{+}}\) as the sequences with terms in the set \(\{1,\ldots ,p-1\}\) and the corresponding ordinary generating functions \(Y_{p}(x)\), \(Z_{p}(x)\) as the power series in \(\mathbb {C}[[x]]\). Then both \(Y_{p}\), \(Z_{p}\) are analytic in the circle \(|x|<1\) and are transcendental over \(\mathbb {C}(x)\).

Proof

Because \(y_{p}(n), z_{p}(n)\in \{1,\ldots ,p-1\}\) (treated as elements in \(\mathbb {Z}\)), then it is clear that the series \(Y_{p}(x)\) and \(Z_{p}(x)\) are absolutely convergent in the set \(\{x\in \mathbb {C}:\;|x|<1\}\) and thus define analytic functions. From Corollary 4.2 and the fact that \(0<y_{p}(n),z_{p}(n)<p\), we get that \(z_{p}(n)=p-y_{p}(n)\) for all \(n\in \mathbb {N}_{+}\). Thus simply

$$\begin{aligned} Z_{p}(x)=\frac{p}{1-x}-Y_{p}(x). \end{aligned}$$

Therefore, in order to get the transcendence of the functions \(Y_{p}(x)\) and \(Z_{p}(x)\), it is enough to prove it only for \(Y_{p}(x)\).

In the proof of Theorem 4.1 we obtained the functional equation for the function \(Y_{p}(x)\):

$$\begin{aligned} Y_{p}(x)=x^{p-1}Y_{p}(x^{p})+\frac{W_{p}(x)}{1-x^{p}}, \end{aligned}$$

where \(W_{p}(x)=\sum _{n=1}^{p-1}(n^{-1}\mod p)x^{n-1}\). This equation was proved in fact over \(\mathbb {C}\), not only over \(\mathbb {F}_{p}\) (because all equalities in this case were ’true’ equalities, i.e., not equalities modulo p).

The transcendence of \(Y_{p}\) will be consequence of a general result of Nishioka [9]. This result says that a power series, say f, with rational coefficients, which defines an analytic function in some neighborhood of zero and satisfying functional equation of the form \(f(x)=A(x)+B(x)f(x^{m})\) for some \(m\in \mathbb {N}_{\ge 2}\) and functions \(A, B\in \mathbb {C}(x)\), is either rational of transcendental. In the light of this remark we see that in order to get transcendence of \(Y_{p}\) it is enough to prove that our function is not rational.

Let us suppose that \(Y_{p}(x)\) is rational, i.e., \(Y_{p}(x)=P(x)/Q(x)\) for some \(P, Q\in \mathbb {C}[x]\) with \(\gcd (P(x),Q(x))=1\). Putting the expression for \(Y_{p}\) into the functional equation and clearing the denominators we get the equation

$$\begin{aligned} (1-x^{p})P(x)Q(x^{p})=(1-x^{p})x^{p-1}P(x^{p})Q(x)+Q(x)Q(x^{p})W_{p}(x). \end{aligned}$$
(6)

From the above equation we get \(Q(x^{p})\mid (1-x^{p})x^{p-1}P(x^{p})Q(x)\). However, the co-primality of the polynomials P(x), Q(x) implies co-primality of the polynomials \(P(x^{p}), Q(x^{p})\) and thus we get

$$\begin{aligned} Q(x^{p})\mid (1-x^{p})x^{p-1}Q(x). \end{aligned}$$

Consequently \(p{\text {deg}}Q\le 2p-1+{\text {deg}}Q\) and thus \({\text {deg}}Q\le 2+\frac{1}{p-1}\). We thus see that the degree of the polynomial Q is bounded by 2.

Let us put \(x=1\) in (6). We get that \(Q(1)^{2}W_{p}(1)=0\), but \(W_{p}(1)>0\), so \(Q(1)=0\). In particular, \(\deg Q\ge 1\) and we can write \(Q(x)=(1-x)S(x)\). Plug it into (6) and get after dividing by \(1-x\):

$$\begin{aligned} \frac{1-x^{p}}{1-x}P(x)S(x^{p})=x^{p-1}P(x^{p})S(x)+S(x)S(x^{p})W_{p}(x). \end{aligned}$$
(7)

If \(\deg Q=1\), then S is a constant, say \(S(x)=S_{0}\ne 0\). Equation (7) implies

$$\begin{aligned} W_{p}(x)=\frac{1}{S_{0}} \left( \frac{1-x^{p}}{1-x}P(x)-x^{p-1}P(x^{p})\right) . \end{aligned}$$

Observe that \(\deg W_{p}(x)=p-2\). If \(\deg P\ge 1\), then the degree of the polynomial of the right-hand side of the last equation is equal to \(\deg (x^{p-1}P(x^{p}))\ge 2p-1>p-2\), a contradiction. Hence, \(\deg P=0\), so we can write \(P(x)=P_{0}\ne 0\). Then we get from the last equation

$$\begin{aligned} W_{p}(x)=\frac{P_{0}}{S_{0}}\left( 1+x+\cdots +x^{p-2}\right) , \end{aligned}$$

that is again a contradiction, since not all coefficients of \(W_{p}(x)\) are equal to each other. Thus we may assume that \(\deg Q=2\) and \(\deg S=1\).

Let us write \(S(x)=S_{1}x+S_{0}\). From (7) we get \(S(x^{p})\mid x^{p-1}P(x^{p})S(x)\), but \(S(x^{p})\) and \(P(x^{p})\) are co-prime, so \(S(x^{p})\mid x^{p-1}S(x)\). Thus there exists a polynomial T(x) such that \(S(x^{p})T(x)=x^{p-1}S(x)\), and by comparing the degrees we get \(\deg T=0\). Comparing the coefficients of \(x^{p-1}\) implies \(S_{0}=0\), i.e., \(S(x)=S_{1}x\). Equation (7) implies

$$\begin{aligned} W_{p}(x)=\frac{1}{S_{1}x}\left( \frac{1-x^{p}}{1-x}P(x)-P(x^{p})\right) . \end{aligned}$$

If \(\deg P\ge 2\), then \(\deg \left( \frac{1}{S_{1}x}\left( \frac{1-x^{p}}{1-x}P(x)-P(x^{p})\right) \right) =p\deg P-1>p-2\). Hence, \(\deg P\le 1\). Write \(P(x)=P_{1}x+P_{0}\). Thus

$$\begin{aligned} W_{p}(x)&=\frac{1}{S_{1}x}\left( \frac{1-x^{p}}{1-x}(P_{1}x+P_{0}) -(P_{1}x^{p}+P_{0})\right) \\&=\frac{P_{1}+P_{0}}{S_{1}}\left( 1+x+\cdots +x^{p-2}\right) , \end{aligned}$$

that is a contradiction.

Summing up our discussion: we proved that there are no polynomials \(P, Q\in \mathbb {C}[x]\) satisfying Eq. (6) and thus the function \(Y_{p}(x)\) cannot be rational. \(\square \)

Remark 4.7

In the above proof, instead of use result of Nishioka, we could use classical result of Fatou: if a power series \(\sum _{n=0}^{\infty }a_{n}x^{n}\) with integer coefficients converges inside the unit disk, then it is either rational or transcendental over \(\mathbb {C}(x)\) [6]. However, it is clear that the burden of the proof lies in the proof of irrationality of \(Y_{p}(x)\).

An immediate consequence of our result is the following.

Corollary 4.8

The sequences \((y_{p}(n))_{n\in \mathbb {N}_{+}}, (z_{p}(n))_{n\in \mathbb {N}_{+}}\) are not periodic.

Proof

It is clear that the ordinary generating function of a periodic sequence is rational. However, in the theorem above we proved that the ordinary generating functions of our sequences are transcendental. \(\square \)

Remark 4.9

One can investigate further properties of the sequence \((y_{p}(n))_{n\in \mathbb {N}_{+}}\). We note only one property. More precisely, one can easily prove the following summation formula:

$$\begin{aligned} \sum _{k=1}^{p^{n}-1}y_{p}(k)=\frac{1}{2}p(p^{n}-1). \end{aligned}$$

5 Further congruences for \(d_{m}(pn)-d_{m}(n)\)

Observe that Theorem 3.5 can be viewed as a generalization of Lemma 3.2. Therefore, it is natural to use this more general fact in order to generalize some of results that we have previously obtained. In the sequel, we will need the following lemma, that is a generalization of Wolstenholme’s theorem [12], which says that for \(p\in {\mathbb {P}}_{\ge 5}\) the following congruence holds:

$$\begin{aligned} \left( {\begin{array}{c}pm\\ pi\end{array}}\right) \equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \ (\mathrm {mod}\ p^{3}). \end{aligned}$$

The Wolstenholme’s theorem is equivalent to the following pair of the congruences:

$$\begin{aligned} \sum _{\gamma =1}^{p-1}\frac{1}{\gamma }\equiv 0\ (\mathrm {mod}\ p^{2}) \ \ \ \ \ \ \ \ \ \ \ \text { and } \ \ \ \ \ \ \ \ \ \ \ \sum _{\gamma =1}^{p-1}\frac{1}{\gamma ^{2}}\equiv 0\ (\mathrm {mod}\ p), \end{aligned}$$

that will be used in the proof.

Lemma 5.1

Let \(m\in \mathbb {N}_{\ge 1}\), \(i\in \{0,\ldots ,m\}\), \(p\in {\mathbb {P}}_{\ge 3}\). Then

$$\begin{aligned} \left( {\begin{array}{c}pm\\ pi\end{array}}\right) \equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \ (\mathrm {mod}\ p^{\nu _{p}(m)+\nu _{p}\left( \left( {\begin{array}{c}m\\ i\end{array}}\right) \right) +3-\chi }), \end{aligned}$$

where \(\chi =[p=3]-\left[ p=3,\ \nu _{3}(m)\ge 1,\ \nu _{3}\left( \left( {\begin{array}{c}m\\ i\end{array}}\right) \right) =0\right] \).

Proof

The statement is obvious if \(i=0\) or \(i=m\). Assume \(1\le i\le m-1\) and denote \(\alpha :=\nu _{p}(m)\). Then

$$\begin{aligned} \left( {\begin{array}{c}pm\\ pi\end{array}}\right)&= \frac{\prod _{j=0}^{pi-1}(pm-j)}{\prod _{j=1}^{pi}j}=\prod _{j=1}^{i}\frac{pm-pj+p}{pj}\prod _{j=0}^{i-1}\prod _{\beta =1}^{p-1}\frac{pm-pj-\beta }{pj+\beta }\\&=\left( {\begin{array}{c}m\\ i\end{array}}\right) \prod _{j=0}^{i-1}\prod _{\beta =1}^{p-1}\frac{pm-(pj+\beta )}{pj+\beta }. \end{aligned}$$

In order to finish the proof, it is enough to show that for each j:

$$\begin{aligned} \prod _{\beta =1}^{p-1}(pm-(pj+\beta ))\equiv \prod _{\beta =1}^{p-1}(pj+\beta )\ (\mathrm {mod}\ p^{\alpha +3}). \end{aligned}$$

We have

$$\begin{aligned}&\prod _{\beta =1}^{p-1}(pm-(pj+ \beta )) - \prod _{\beta =1}^{p-1}(pj+\beta ) \\&\quad \equiv p^{2}m^{2}\sum _{\gamma _{1}<\gamma _{2}} \prod _{\begin{array}{c} \beta =1 \\ \beta \ne \gamma _{1},\gamma _{2} \end{array}}^{p-1}(pj+\beta )-pm\sum _{\gamma =1}^{p-1}\prod _{\begin{array}{c} \beta =1 \\ \beta \ne \gamma \end{array}}^{p-1}(pj+\beta ) \\&\qquad +\prod _{\beta =1}^{p-1}(pj+\beta )-\prod _{\beta =1}^{p-1}(pj+\beta ) \\&\quad = \prod _{\beta =1}^{p-1}(pj+\beta )\left( p^{2}m^{2}\sum _{\gamma _{1}<\gamma _{2}}\frac{1}{(pj+\gamma _{1})(pj+\gamma _{2})}\right. \\&\qquad \left. -pm\sum _{\gamma =1}^{p-1}\frac{1}{pj+\gamma }\right) \ (\mathrm {mod}\ p^{\alpha +3}). \end{aligned}$$

If \(p=3\) and \(\nu _{3}(m)\) and \(\nu _{3}\left( \left( {\begin{array}{c}m\\ i\end{array}}\right) \right) \) are arbitrary, we are in fact interested in the congruence modulo \(p^{\alpha +2}\) instead of \(p^{\alpha +3}\). In that case, the quantity in the brackets simplifies to

$$\begin{aligned} -pm\sum _{\gamma =1}^{p-1}\frac{1}{pj+\gamma }\equiv -pm\sum _{\gamma =1}^{p-1}\frac{1}{\gamma }\equiv -pm\sum _{\gamma =1}^{p-1}\gamma =-p^{2}m\frac{p-1}{2}\equiv 0\ (\mathrm {mod}\ p^{\alpha +2}), \end{aligned}$$

so the statement holds. When \(p=3\) and additionally \(\nu _{3}(m)\ge 1\) and \(\nu _{3}\left( \left( {\begin{array}{c}m\\ i\end{array}}\right) \right) =0\), then \(3^{\alpha +3}\mid 3^{2}m^{2}\), so the expression in the square brackets simplifies in the same way as before. Hence,

$$\begin{aligned}&\prod _{\beta =1}^{3-1}(3m-(3j+\beta )) - \prod _{\beta =1}^{3-1}(3j+\beta )\\&\quad = (3m-(3j+1))(3m-(3j+2))-(3j+1)(3j+2) \\&\quad \equiv -3m(3j+1)(3j+2)\left( \frac{1}{3j+1}+\frac{1}{3j+2}\right) \\&\quad = -3m(3j+1)(3j+2)\frac{6j+3}{(3j+1)(3j+2)} \\&\quad = -9m(2j+1)\equiv 9m(j-1) \ (\mathrm {mod}\ p^{\alpha +3}). \end{aligned}$$

Therefore,

$$\begin{aligned} (3m-(3j+1))(3m-(3j+2))\equiv (3j+1)(3j+2)+9m(j-1)\ (\mathrm {mod}\ p^{\alpha +3}). \end{aligned}$$

The conditions \(3\mid m\) and \(3\not \mid \left( {\begin{array}{c}m\\ i\end{array}}\right) \) imply \(3\mid i\). Thus

$$\begin{aligned} \left( {\begin{array}{c}3m\\ 3i\end{array}}\right)&\equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \prod _{j=0}^{i-1}\frac{(3m-(3j+1))(3m-(3j+2))}{(3j+1)(3j+2)}\\&\equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \prod _{j=0}^{i-1} \left( 1+\frac{9m(j-1)}{(3j+1)(3j+2)}\right) \\&\equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \prod _{j=0}^{i-1}\left( 1-9m(j-1)\right) \equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \left( 1-9m\sum _{j=0}^{i-1}(j-1)\right) \\&\equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \left( 1-9m\left( \frac{i(i-1)}{2}-i\right) \right) \equiv \left( {\begin{array}{c}m\\ i\end{array}}\right) \ (\mathrm {mod}\ p^{\alpha +3}). \end{aligned}$$

The proof of this case is complete.

Assume that \(p\ge 5\). Wolstenholme’s Theorem implies

$$\begin{aligned} \sum _{\gamma =1}^{p-1}\frac{1}{pj+\gamma }&= \frac{1}{2}\sum _{\gamma =1}^{p-1}\left( \frac{1}{pj+\gamma } +\frac{1}{pj+p-\gamma }\right) \\&= \frac{p}{2}\sum _{\gamma =1}^{p-1}\frac{2j+1}{(pj+\gamma )(pj+p-\gamma )}\\&\equiv -(2j+1)\frac{p}{2}\sum _{\gamma =1}^{p-1}\frac{1}{\gamma ^{2}}\equiv 0\ (\mathrm {mod}\ p^{2}), \end{aligned}$$

and

$$\begin{aligned} \sum _{\gamma =1}^{p-1}\frac{1}{(pj+\gamma )^{2}}\equiv \sum _{\gamma =1}^{p-1}\frac{1}{\gamma ^{2}}\equiv 0\ (\mathrm {mod}\ p). \end{aligned}$$

Therefore,

$$\begin{aligned} \sum _{\gamma _{1}<\gamma _{2}}\frac{1}{(pj+\gamma _{1})(pj+\gamma _{2})} =\frac{1}{2}\left[ \left( \sum _{\gamma =1}^{p-1}\frac{1}{pj+\gamma }\right) ^{2}-\sum _{\gamma =1}^{p-1}\frac{1}{(pj+\gamma )^{2}}\right] \equiv 0\ (\mathrm {mod}\ p). \end{aligned}$$

Hence, indeed

$$\begin{aligned} \prod _{\beta =1}^{p-1}(pm-(pj+\beta ))\equiv \prod _{\beta =1}^{p-1}(pj+\beta )\ (\mathrm {mod}\ p^{\alpha +3}) \end{aligned}$$

and the proof is finished. \(\square \)

Remark 5.2

For \(i=1\), it is possible to strengthen the result. Indeed, using the techniques from the proof of Lemma 5.3 we get

$$\begin{aligned} \left( {\begin{array}{c}pm\\ p\end{array}}\right) -m&= m\left( \frac{(pm-1)\ldots (pm-p+1)}{(p-1)!}-1\right) \\&= \frac{m}{(p-1)!}\left( (p(m-1)+p-1)(p(m-1)+p-2)\ldots \right. \\&\qquad \qquad \quad \left. (p(m-1)+1)-(p-1) !\right) \\&\equiv m\left( p^{2}(m-1)^{2}\sum _{\gamma _{1}<\gamma _{2}}\frac{1}{\gamma _{1}\gamma _{2}} +p(m-1)\sum _{\gamma =1}^{p-1}\frac{1}{\gamma }\right) \\&\quad \times \ (\mathrm {mod}\ p^{\nu _{p}(m)+\nu _{p}(m-1)+3-\chi }). \end{aligned}$$

We can repeat the proof of the previous fact and get result modulo \(p^{\nu _{p}(m)+\nu _{p}(m-1)+3-\chi }\). Observe that at most one of the number \(\nu _{p}(m)\) and \(\nu _{p}(m-1)\) may be non-zero. Hence, if \(\nu _{p}(m-1)=0\), we can still apply Lemma 5.3 that is better in this case. Finally, we get

$$\begin{aligned} \left( {\begin{array}{c}pm\\ p\end{array}}\right) \equiv m \ (\mathrm {mod}\ p^{2\nu _{p}(m)+\nu _{p}(m-1)+3-\chi }). \end{aligned}$$

However, we will not need this fact later.

Now we want to state a stronger version of Lemma 3.3. Let us define

$$\begin{aligned} \vartheta _{m}(n):=d_{m}(pn)-d_{m}(n). \end{aligned}$$

Lemma 5.3

Let \(p\in {\mathbb {P}}_{\ge 3}\), \(m\in \mathbb {N}_{\ge 1}\). Then \(\vartheta _{m}(1)\equiv 0\ (\mathrm {mod}\ p^{2\nu _{p}(m)+3-[p=3]})\) and

$$\begin{aligned} \sum _{i=0}^{\min \{m,n\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) \vartheta _{m}(n-i)\equiv (-1)^{n+1}\left[ \left( {\begin{array}{c}pm\\ pn\end{array}}\right) -\left( {\begin{array}{c}m\\ n\end{array}}\right) \right] \ (\mathrm {mod}\ p^{2\nu _{p}(m)+3-[p=3]}). \end{aligned}$$

Proof

We prove only the case \(p\ge 5\). If \(p=3\), the proof is analogous and in fact simpler because of some additional cancellations. Let us write \(m=p^{\alpha }k\), where \(p\not \mid k\). For \(n=1\) we have

$$\begin{aligned} d_{m}(p)&= -\sum _{i=1}^{p}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(p-i) +d_{m}(1)-md_{m}(0) \\&= d_{m}(1)+\left[ \left( {\begin{array}{c}pm\\ p\end{array}}\right) -m\right] d_{m}(0)-\sum _{i=1}^{p-1}(-1)^{i} \left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(p-i). \end{aligned}$$

By Lemma 5.1 we get that \(p^{2\alpha +3}\mid \left( {\begin{array}{c}pm\\ p\end{array}}\right) -m\). Moreover,

$$\begin{aligned} \left( {\begin{array}{c}pm\\ i\end{array}}\right) =pm\frac{(pm-1)\ldots (pm-i+1)}{i!}\equiv pm\frac{(-1)^{i-1}}{i}\ (\mathrm {mod}\ p^{\alpha +2}) \end{aligned}$$

and using Theorem 3.5 we obtain the congruence

$$\begin{aligned} \sum _{i=1}^{p-1}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(n-i)&\equiv \sum _{i-1}^{p-1}(-1)^{i}pm\frac{(-1)^{i-1}}{i} \frac{pm}{i}\\&=-p^{2}m^{2}\sum _{i=1}^{p-1}\frac{1}{i^{2}}\equiv 0\ (\mathrm {mod}\ p^{2\alpha +3}). \end{aligned}$$

Thus always \(d_{m}(p)\equiv d_{m}(1)\ (\mathrm {mod}\ p^{2\alpha +3})\), i.e., \(\vartheta _{m}(1)\equiv 0\ (\mathrm {mod}\ p^{2\alpha +3})\). Now assume that n is arbitrary . The recurrence relation for \(d_{m}(n)\) gives

$$\begin{aligned} d_{m}(pn)&= -\sum _{i=1}^{\min \{pm,pn\}}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(pn-i) +\sum _{i=0}^{\min \{m,n\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i) \\&= d_{m}(n) -\sum _{\begin{array}{c} i=1 \\ p\not \mid i \end{array}}^{\min \{pm,pn\}}(-1)^{i}\left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(pn-i) \\&\quad +\sum _{i=1}^{\min \{m,n\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i) -\sum _{i=1}^{\min \{m,n\}}(-1)^{pi}\left( {\begin{array}{c}pm\\ pi\end{array}}\right) d_{m}(pn-pi) \\&= d_{m}(n)+ \Sigma _{1}+\Sigma _{2}, \end{aligned}$$

where

$$\begin{aligned} \Sigma _{1}&= -\sum _{\begin{array}{c} i=1 \\ p\not \mid i \end{array}}^{\min \{pm,pn\}}(-1)^{i} \left( {\begin{array}{c}pm\\ i\end{array}}\right) d_{m}(pn-i), \\ \Sigma _{2}&= \sum _{i=1}^{\min \{m,n\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) d_{m}(n-i)-\sum _{i=1}^{\min \{m,n\}}(-1)^{i} \left( {\begin{array}{c}pm\\ pi\end{array}}\right) d_{m}(p(n-i)). \end{aligned}$$

At first, we deal with \(\Sigma _{1}\). Observe that if \(i=\delta p+\gamma \) for some \(\delta \in \mathbb {N}\) and \(\gamma \in \{1,\ldots ,p-1\}\), then

$$\begin{aligned} \left( {\begin{array}{c}pm\\ i\end{array}}\right)&= pm\frac{(pm-1)\ldots (pm-i+1)}{i!}\\&=pm\frac{\prod _{j=1}^{\delta }(pm-pj)}{\prod _{j=1}^{\delta }pj} \cdot \frac{\prod _{j=1,p\not \mid j}^{i-1}(pm-j)}{\prod _{j=1,p\not \mid j}^{i-1}j}\cdot \frac{1}{i} \\&\equiv pm\prod _{j=1}^{\delta }\frac{m-j}{j}\cdot \frac{\prod _{j=1,p\not \mid j}^{i-1}(-j)}{\prod _{j=1,p\not \mid j}^{i-1}j}\cdot \frac{1}{i}\\&=pm\prod _{j=1}^{\delta }\frac{m-j}{j} \cdot (-1)^{i-1-\delta }\cdot \frac{1}{i} \ (\mathrm {mod}\ p^{\alpha +2}). \end{aligned}$$

Hence,

$$\begin{aligned} \Sigma _{1}&\equiv -\sum _{\begin{array}{c} i=1 \\ p\not \mid i \end{array}}^{\min \{pm,pn\}}(-1)^{i}pm\prod _{j=1}^{\left\lfloor \frac{i}{p} \right\rfloor }\frac{m-j}{j}\cdot (-1)^{i-1-\left\lfloor \frac{i}{p}\right\rfloor }\cdot \frac{1}{i}\cdot \frac{pm}{-i} \\&= -p^{2}m^{2}\sum _{l=0}^{\min \{m-1,n-1\}}\sum _{r=1}^{p-1}(-1)^{l} \frac{1}{(pl+r)^{2}}\prod _{j=1}^{l}\frac{m-j}{j} \\&= -p^{2}m^{2}\sum _{l=0}^{\min \{m-1,n-1\}}(-1)^{l}\prod _{j=1}^{l} \frac{m-j}{j}\sum _{r=1}^{p-1}\frac{1}{(pl+r)^{2}} \\&\equiv -p^{2}m^{2}\sum _{l=0}^{\min \{m-1,n-1\}}(-1)^{l} \prod _{j=1}^{l}\frac{m-j}{j}\sum _{r=1}^{p-1}\frac{1}{r^{2}} \\&\equiv -p^{2}m^{2}\left( \sum _{r=1}^{p-1}r^{2}\right) \left( \sum _{l=0}^{\min \{m-1,n-1\}}(-1)^{l}\prod _{j=1}^{l}\frac{m-j}{j}\right) \\&= -p^{3}m^{2}\frac{(p-1)(2p-1)}{6} \left( \sum _{l=0}^{\min \{m-1,n-1\}}(-1)^{l}\prod _{j=1}^{l}\frac{m-j}{j} \right) \equiv 0\ (\mathrm {mod}\ p^{2\alpha +3}). \end{aligned}$$

Now we focus on \(\Sigma _{2}\). We can write

$$\begin{aligned} \Sigma _{2}&= \sum _{i=1}^{\min \{m,n\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) \left[ d_{m}(n-i)-d_{m}(p(n-i))\right] \\&\quad -\sum _{i=1}^{\min \{m,n\}}(-1)^{i} \left[ \left( {\begin{array}{c}pm\\ pi\end{array}}\right) -\left( {\begin{array}{c}m\\ i\end{array}}\right) \right] d_{m}(p(n-i)) \\&\equiv -\sum _{i=1}^{\min \{m,n\}}(-1)^{i}\left( {\begin{array}{c}m\\ i\end{array}}\right) \vartheta _{m}(n-i)+(-1)^{n+1}\left[ \left( {\begin{array}{c}pm\\ pn\end{array}}\right) -\left( {\begin{array}{c}m\\ n\end{array}}\right) \right] \ (\mathrm {mod}\ p^{2\alpha +3}), \end{aligned}$$

because \(p^{\alpha +3}\mid \left( {\begin{array}{c}pm\\ pn\end{array}}\right) -\left( {\begin{array}{c}m\\ n\end{array}}\right) \) by Lemma 5.1, and \(p^{\alpha +1}\mid d_{m}(p(n-i))\) for \(i\ne n\). The result follows. \(\square \)

Remark 5.4

From the above result we can write exact expression for the remainder of the division of \(d_{m}(pn)-d_{m}(p)\) by \(p^{2\nu _{p}(m)+3-[p=3]}\). More precisely, let

$$\begin{aligned} \Theta _{m}(x):=\sum _{n=0}^{\infty }\vartheta _{m}(n)x^{n} \end{aligned}$$

be the generating function of the sequence \((\vartheta _{m}(n))_{n=0}^{\infty }\). Lemma 5.3 can be restated in the following way:

$$\begin{aligned} (1-x)^{m}\Theta _{m}(x)&\equiv \sum _{n=0}^{m}(-1)^{n+1} \left[ \left( {\begin{array}{c}pm\\ pn\end{array}}\right) -\left( {\begin{array}{c}m\\ n\end{array}}\right) \right] x^{n} \\&\equiv \sum _{n=0}^{m}(-1)^{n+1}\left( {\begin{array}{c}pm\\ pn\end{array}}\right) x^{n}+(1-x)^{m} \ (\mathrm {mod}\ p^{2\nu _{p}(m)+3-[p=3]}). \end{aligned}$$

Equivalently, due to the identity

$$\begin{aligned} \frac{1}{(1-x)^{m}}=\sum _{n=0}^{\infty }\left( {\begin{array}{c}n+m-1\\ n\end{array}}\right) x^{n}, \end{aligned}$$

we get the congruence

$$\begin{aligned} \Theta _{m}(x)&\equiv \left( \sum _{n=0}^{\infty } \left( {\begin{array}{c}n+m-1\\ n\end{array}}\right) x^{n}\right) \left( \sum _{n=0}^{m}(-1)^{n+1} \left( \left( {\begin{array}{c}pm\\ pn\end{array}}\right) -\left( {\begin{array}{c}m\\ n\end{array}}\right) \right) x^{n}\right) \\&\equiv \sum _{n=0}^{\infty }\left( \sum _{k=0}^{{\text {min}}\{m,n\}}(-1)^{k+1} \left( \left( {\begin{array}{c}pm\\ pk\end{array}}\right) -\left( {\begin{array}{c}m\\ k\end{array}}\right) \right) \left( {\begin{array}{c}n-k+m-1\\ n-k\end{array}}\right) \right) \\&\quad x^{n} \ (\mathrm {mod}\ p^{2\nu _{p}(m)+3-[p=3]}). \end{aligned}$$

Observe that we can also rewrite the above functional equation for \(\Theta _{m}\) as

$$\begin{aligned} -1+\Theta _{m}(x)&\equiv \frac{\sum _{n=0}^{m}(-1)^{n+1} \left( {\begin{array}{c}pm\\ pn\end{array}}\right) }{(1-x)^{m}} \\&= \sum _{n=0}^{\infty }\left( \sum _{k=0}^{{\text {min}}\{m,n\}}(-1)^{k+1} \left( {\begin{array}{c}pm\\ pk\end{array}}\right) \left( {\begin{array}{c}n-k+m-1\\ n-k\end{array}}\right) \right) \\&\quad \times x^{n}\ (\mathrm {mod}\ p^{2\nu _{p}(m)+3-[p=3]}). \end{aligned}$$

Thus simply

$$\begin{aligned} \begin{aligned}&d_{m}(pn)-d_{m}(n)\\&\quad \equiv \sum _{k=0}^{{\text {min}}\{m,n\}}(-1)^{k+1} \left( \left( {\begin{array}{c}pm\\ pk\end{array}}\right) -\left( {\begin{array}{c}m\\ k\end{array}}\right) \right) \left( {\begin{array}{c}n-k+m-1\\ n-k\end{array}}\right) \\&\quad \equiv \sum _{k=0}^{{\text {min}}\{m,n\}}(-1)^{k+1}\left( {\begin{array}{c}pm\\ pk\end{array}}\right) \left( {\begin{array}{c}n-k+m-1\\ n-k\end{array}}\right) \ (\mathrm {mod}\ p^{2\nu _{p}(m)+3-[p=3]}) \end{aligned} \end{aligned}$$

for all \(n\ge 1\).

Lemma 5.3 allow us to simply get the following theorem concerning the problem of finding natural numbers k such that the congruence \(d_{m}(pn)\equiv d_{m}(n)\ (\mathrm {mod}\ p^{\nu _{p}(m)+k})\) holds for all \(n\ge 1\).

Theorem 5.5

Let \(m\in \mathbb {N}_{\ge 1}\) and \(p\in {\mathbb {P}}_{\ge 3}\). If one of the following conditions holds:

  1. 1.

    \(p\ge 5\),

  2. 2.

    \(p=3\) and \(\nu _{3}(m)\ge 1\),

then the congruence

$$\begin{aligned} d_{m}(pn)\equiv d_{m}(n)\ (\mathrm {mod}\ p^{\nu _{p}(m)+3}) \end{aligned}$$

is true for all \(n\ge 1\).

Proof

It is easy to check that if p and m satisfy one of the conditions from the statement then \(2\nu _{p}(m)+3-[p=3]\ge \nu _{p}(m)+3\). Lemma 5.3 implies that in order to prove the theorem, it is enough to show that \(p^{\alpha +3}\mid \left( {\begin{array}{c}pm\\ pi\end{array}}\right) -\left( {\begin{array}{c}m\\ i\end{array}}\right) \) for p and m satisfying one of the conditions from the statement, and \(i\in \{1,\ldots ,m\}\). If \(p\ge 5\) it follows directly from Lemma 5.1. Assume \(p=3\) and \(\nu _{3}(m)\ge 1\). From Lemma 5.1 it is enough to show that then \(\nu _{p}\left( \left( {\begin{array}{c}m\\ i\end{array}}\right) \right) +3-\chi \ge 3\), i.e., \(\nu _{p}\left( \left( {\begin{array}{c}m\\ i\end{array}}\right) \right) \ge \chi \). If \(3\mid i\) this is obvious because \(\chi =0\) then. If \(3\not \mid i\), then \(3\mid \left( {\begin{array}{c}m\\ i\end{array}}\right) \), so \(\nu _{p}\left( \left( {\begin{array}{c}m\\ i\end{array}}\right) \right) \ge 1=\chi \), so the inequality is also satisfied. \(\square \)

6 Questions, problems and conjectures

In this section we collect some questions, problems and conjectures which appeared during our work.

It is well known that if \(k\in \mathbb {N}_{+}\) and \(t\equiv 1 \ (\mathrm {mod}\ 2)\), then

$$\begin{aligned} c_{1}(2^{2k+1}t)-c_{1}(2^{2k-1}t)&\equiv 0\ (\mathrm {mod}\ 2^{3k+2}),\\ c_{1}(2^{2k}t)-c_{1}(2^{2k-2}t)&\equiv 0\ (\mathrm {mod}\ 2^{3k}) \end{aligned}$$

(remember \(c_{1}(n)=b(2n)\), where b(n) counts the binary partitions of n). The above congruences were conjectured by Churchhouse in [4] and independently proved by Rödseth [10] and Gupta [8]. Moreover, it is known that there is no higher power of 2 which divides \(c_{1}(4n)-c_{1}(n)\). These results generated a lot of research devoted to certain differences connected with other partition functions. This result motivates the question concerning the divisibility of the number \(c_{m}(2^{k+2}n)-c_{m}(2^{k}n)\) by powers of 2. We performed some numerical computations in case of \(m\in \{2,3,\ldots ,10\}\) and \(n\le 10^5\) and believe that the following is true.

Conjecture 6.1

For \(k\in \mathbb {N}_{+}\) and each \(n\in \mathbb {N}_{+}\), we have

$$\begin{aligned} \nu _{2}(c_{2k}(4n)-c_{2k}(n))=\nu _{2}(n)+2\nu _{2}(k)+3. \end{aligned}$$

Moreover, for \(k\in \mathbb {N}\) and \(n\in \mathbb {N}_{+}\) the following inequalities hold:

$$\begin{aligned} \nu _{2}(c_{4k+1}(4n)-c_{4k+1}(n))&\ge \nu _{2}(n)+3,\\ \nu _{2}(c_{4k+3}(4n)-c_{4k+3}(n))&\ge \nu _{2}(n)+6. \end{aligned}$$

In each case the equality holds for infinitely many \(n\in \mathbb {N}\).

In case of \(p\in {\mathbb {P}}_{\ge 3}\) we can use Theorem 5.5 to get some information about the behavior of the differences \(d_{m}(p^{2}n)-d_{m}(n)\) modulo powers of p. However, we predict that results obtained in this way are far from being optimal. For example, a direct application of Theorem 5.5 gives

$$\begin{aligned}&d_{m}(p^{2}n)-d_{m}(n)\\&\qquad =\left( d_{m}(p^{2}n)-d_{m}(pn)\right) +\left( d_{m}(pn)-d_{m}(n)\right) \\&\qquad \equiv 0\ (\mathrm {mod}\ p^{\nu _{p}(m)+3}). \end{aligned}$$

On the other hand, we believe that the following, much stronger property, is true.

Conjecture 6.2

Assume that \(m=pk+i\) for some \(k\in \mathbb {N}\) and \(i\in \{0,\ldots ,p-1\}\). Then we have the following equality:

$$\begin{aligned} \nu _{p}(d_{m}(p^2n)-d_{m}(n))=\nu _{p}(n)+2\nu _{p}(m)+3-[p=3]. \end{aligned}$$

In the case \(i=p-1\) the following inequality is true:

$$\begin{aligned} \nu _{p}(d_{pk+p-1}(p^2n)-d_{pk+p-1}(n))\ge \nu _{p}(n)+4-[p=3]. \end{aligned}$$

For infinitely many values of n the above inequality is an equality.

In light of results obtained in the previous section, it is quite natural to ask about existence of pairs \(m\in \mathbb {N}_{+}\) and \(k\in \mathbb {N}_{\ge 3}\) such that the following congruence

$$\begin{aligned} d_{m}(pn)\equiv d_{m}(n)\ (\mathrm {mod}\ p^{\nu _{2}(m)+k}) \end{aligned}$$
(8)

holds. We performed numerical search for values of \(m\in \{2,\ldots ,100\}\) such that the congruence (8) is satisfied for \(k=5\) or \(k=6\), \(p\in \{3, 5, \ldots , 29\}\) and all \(n\le 10^3\). For \(k=5\) we found the following pairs:

$$\begin{aligned} (p,m)&= (3,26), (3,27), (3,53), (3,54), (3,80), (3,81), (5,24), (5,25), (5,49),\\&\quad (5,50), (5,74), (5,75), (5,99), (5,100), (7,48), (7,49), (7,97), (7,98). \end{aligned}$$

Among the above pairs only the pairs \((p,m)=(3,80), (3,81)\) extend to solutions of (8) with \(k=6\).

We formulate the following general.

Problem 6.3

For which triples \((p, m, k)\in {\mathbb {P}}_{\ge 3}\times \mathbb {N}_{+}\times \mathbb {N}_{\ge 3}\) the congruence (8) holds for all \(n\in \mathbb {N}_{+}\)?

Let \(p\in {\mathbb {P}}\) and for \(n\in \mathbb {N}_{+}\) write \(n=\sum _{i=0}^{k}\varepsilon _{i}p^{i}\), where \(\varepsilon _{i}\in \{0,1,\ldots ,p-1\}\) and \(k\le \log _{p} n\). This representation is just the (unique) p-ary expansion of n in base p. Let us observe that the equality \(\nu _{p}(n)=u\) implies \(\varepsilon _{0}=\cdots =\varepsilon _{u-1}=0\) and \(\varepsilon _{u}\ne 0\) in the above representation. Thus, if \(m\in \mathbb {Z}{\setminus }\{-1\}\) is fixed, our results concerning the exact value of \(\nu _{2}(c_{m}(n))\) and \(\nu _{p}(d_{m}(n))\) for \(p\in {\mathbb {P}}_{\ge 3}\) given in Theorems 2.4, 3.5 and 3.7 respectively, imply that the set of values of the numbers of trailing zeros in the binary expansion of \(c_{m}(n)\) and p-ary expansion of \(d_{m}(n)), n\in \mathbb {N}_{+}\), is bounded. This observation suggests the question whether the index of the next non-zero digit in the binary expansion in \(c_{m}(n)\) or p-ary expansion of \(d_{m}(n)\) is in bounded distance from the first one. We state this in equivalent form as the following.

Question 6.4

Let \(m\in \mathbb {N}_{+}\) and write

$$\begin{aligned} u_{m}(n)= & {} \nu _{2}\left( \frac{c_{m}(n)}{2^{\nu _{2}(c_{m}(n))}}-1\right) ,\\ v_{p,m}(n)= & {} \nu _{p}\left( \frac{d_{m}(n)}{p^{\nu _{p}(d_{m}(n))}}-\left[ \frac{d_{m}(n)}{p^{\nu _{p}(d_{m}(n))}}\ (\mathrm {mod}\ p)\right] \right) , \end{aligned}$$

where \(p\in {\mathbb {P}}_{\ge 3}\). Does there exist \(m\in \mathbb {N}_{+}\) such that some of the sequences \((u_{m}(n))_{n\in \mathbb {N}_{+}}, (v_{p,m}(n))_{n\in \mathbb {N}_{+}}\) has finite set of values?

In order to see what is going on, we performed numerical computations for \(m\in \{1,\ldots , 100\}\) and \(n\le 10^5\). We observed that in the considered range there are many values of m such that the set of values of the sequence \((u_{m}(n))_{n\in \mathbb {N}}\) is small (we looked for sets with cardinality \(\le 4\)). We define:

$$\begin{aligned} M_{m}(x):={\text {max}}\{u_{m}(n):\;n\le x\},\quad L_{m}(x):=|\{u_{m}(n):\;n\le x\}|. \end{aligned}$$

In Table 1 we present the results of our computations.

Table 1 Values of \(m\in \{1,\ldots , 100\}\) such that \(L_{m}(10^5)\le 4\) together with the largest value of \(u_{m}(n)\) for \(n\le 10^5\)

Our numerical computations strongly suggest that there should be infinitely many \(m\in \mathbb {Z}\) such that the sequence \((u_{m}(n))_{n\in \mathbb {N}}\) is bounded. We even dare to formulate the following.

Conjecture 6.5

Let \(k\in \mathbb {N}_{+}\) and \(m=2^{2k}-1\). Then the sequence \((u_{m}(n))_{n\in \mathbb {N}}\) is bounded.

In fact, we expect that for \(n\in \mathbb {N}\) the inequality \(u_{2^{2k}-1}(n)\le 2k\) is true.

In case of \(p\in {\mathbb {P}}_{\ge 3}\) we expect that for all \(m\in \mathbb {N}_{+}\) the sequence \((v_{p,m}(n))_{n\in \mathbb {N}_{+}}\) is unbounded.

Finally, let us note that in earlier sections we proved results concerning the p-adic behavior of the sequence \((d_{m}(n))_{n\in \mathbb {N}}\) with \(p\in {\mathbb {P}}\) and \(m\in \mathbb {Z}{\setminus }\{0\}\). A first question which comes to mind is whether anything similar can be proved for the sequence \((S_{k,m}(n))_{n\in \mathbb {N}}\), where k is not a prime number. Here we back to our general definition of \(S_{k,m}(n)\) as the n-th coefficient in the power series expansion of \(H_{k,m}(x)\). We thus ask about the behavior of \(\varphi _{k}(S_{k,m}(n))\), where \(\varphi _{k}:\;\mathbb {N}\rightarrow \mathbb {N}\) is an analog of the p-adic valuation function, i.e., for given \(n\in \mathbb {N}\) we define

$$\begin{aligned} \varphi _{k}(n):=\max \{s\in \mathbb {N}:\;k^{s}\mid n\}\quad \text{ and }\quad \varphi _{k}(0):=+\infty . \end{aligned}$$

It is clear that if \(k\not \in {\mathbb {P}}\), then the function \(\varphi _{k}\) is not additive. Indeed, if \(k=k_{1}k_{2}\) with \(k_{1}, k_{2}>1\) and \(n_{1}=k_{1}u_{1}, n_{2}=k_{2}u_{2}\) with \(\gcd (u_{1}u_{2},k)=1\), then \(\varphi _{k}(n_{1}n_{2})=1\ne \varphi _{k}(n_{1})+\varphi _{k}(n_{2})=0\). However, the question concerning the behavior of the sequence \((\varphi _{k}(S_{m,k}(n))_{n\in \mathbb {N}}\) is still interesting and non-trivial. Moreover, it seems that in the case of composite k some new phenomena arise. We concentrate on the first non-trivial case, i.e., \(k=4\), and formulate several conjectures.

Conjecture 6.6

  1. (1)

    If \(m\equiv 6\ (\mathrm {mod}\ 8)\), then the sequence \((\varphi _{4}(S_{4,m}(n)))_{n\in \mathbb {N}}\) is unbounded.

  2. (2)

    If \(m\not \equiv 6\ (\mathrm {mod}\ 8)\), then the sequence \((\varphi _{4}(S_{4,m}(n)))_{n\in \mathbb {N}}\) is 4-automatic.

  3. (3)

    If \(a_{n}=\varphi _{4}(S_{4,1}(n+1))\), then \(a_{0}=a_{7}=1, a_{1}=a_{3}=0\) and

    $$\begin{aligned} a_{4n+2}= & {} a_{4n},\quad a_{8n+5}=a_{8n+3}=a_{8n+1}=a_{4n+1},\quad \\ a_{16n+7}= & {} a_{2n},\quad a_{16n+15}=a_{n}. \end{aligned}$$
  4. (4)

    If \(b_{n}=\varphi _{4}(S_{4,2}(n+1))\), then \(b_{0}=b_{1}=1, b_{3}=2\) and

    $$\begin{aligned} b_{4n+2}=b_{4n+1}=b_{4n},\quad b_{8n+7}=b_{2n+1},\quad b_{16n+11}=b_{16n+3}=b_{8n+3}. \end{aligned}$$
  5. (5)

    For \(s\in \mathbb {N}_{\ge 2}\) we have

    $$\begin{aligned} \nu _{2}(S_{4,2^{s}}(n))=s+1+(\nu _{2}(2n)\ (\mathrm {mod}\ 2)). \end{aligned}$$

    In particular,

    $$\begin{aligned} \varphi _{4}(S_{4,2^{s}}(n))=\left\lfloor \frac{s+1}{2}\right\rfloor +\left( (s+1)\nu _{2}(2n)\ (\mathrm {mod}\ 2)\right) . \end{aligned}$$
  6. (6)

    For \(s\in \mathbb {N}_{\ge 3}\) and each \(m\in \mathbb {N}\) we have

    $$\begin{aligned} \varphi _{4}(S_{4,2^{s}m+2^{s-1}}(n))=\varphi _{4}(S_{4,2^{s-1}}(n)). \end{aligned}$$

Our numerical calculations suggest that for \(k=p^{a}\) and \(m=p^{b}, a, b\in \mathbb {N}_{+}\), the sequence of the p-adic valuations of \(S_{k,m}(n)\) is p-automatic (and thus bounded). However, we were unable to formulate such nice formula for the corresponding valuation like in the case \(k=4\) and \(m=2^{s}\).

Anyway one can state the following general.

Problem 6.7

For given \(k=p^{a}\), where \(p\in {\mathbb {P}}\) and \(a\in \mathbb {N}_{+}\) characterize those values of \(m\in \mathbb {N}_{+}\) such that the sequence \((\nu _{p}(S_{k,m}(n)))_{n\in \mathbb {N}}\) is p-automatic (is bounded).

Numerical computations suggest the following.

Conjecture 6.8

  1. (1)

    If k is not a power of a prime number, then for each \(m\in \mathbb {N}_{+}\) the sequence \((\varphi _{k}(S_{k,m}(n)))_{n\in \mathbb {N}}\) is unbounded.

  2. (2)

    If k is not a power of a prime number, then for each \(m\in \mathbb {N}_{+}\) the sequence \((\varphi _{k}(S_{k,m}(n)))_{n\in \mathbb {N}}\) is not k-regular.