1 Introduction

There are many papers about equations of the form

$$\begin{aligned} U_n=z_1+\cdots +z_k, \end{aligned}$$
(1)

where \((U_n)_{n=0}^{\infty }\) is a linear recurrence sequence, and \(z_1,\dots ,z_k\) are integers with prime factors coming from a fixed finite set of primes. Here we only refer to the recent papers Guzman-Sanchez and Luca [8], Bertók et al. [1], Bérczes et al. [2], and the (many) references there, where several and various finiteness results have been proved. We mention that there are also many results in the literature where other related problems are discussed. For example, Bravo et al. [4] considered a problem connected to sums of terms of a recurrence sequence yielding perfect powers (also see the references there).

In this paper, we consider the problem of representability of solutions of generalized Pell equations as a fixed term sum of integers with prime factors coming from some finite set of primes. As we shall see, this problem is closely related to Eq. (1). In fact, the problem is more general: it turns out that we need to find sums of the form \(z_1+\cdots +z_k\) in unions of recurrence sequences, rather than in only one fixed sequence. We note that there are some closely related results in the literature. We mention only two recent papers Luca and Togbé [11] and Ddamulira and Luca [5] about the x-coordinates of certain Pell-equations which are (generalized) Fibonacci numbers, and the references therein, and a very fresh one by Erazo et al. [6] on linear combinations of prime powers in the x-coordinates of solutions of Pell equations.

2 New results

Before formulating our theorem, we need to introduce some new notation.

The equation

$$\begin{aligned} x^2-dy^2=t \end{aligned}$$
(2)

is called a generalized Pell equation, where \(d,t\in {\mathbb {Z}}\), \(d>1\) is square-free, and t is a non-zero integer. (Note that the name Pell equation usually refers to the cases \(t=\pm 1,\pm 4\), while for the other values of t, (2) is a norm form equation in \({\mathbb {Q}}(\sqrt{d})\).) Write X and Y for the sets of solutions of Eq. (2) in \(x\in {\mathbb {Z}}\) and \(y\in {\mathbb {Z}}\), respectively.

Let \(p_1,\dots ,p_\ell \) be distinct primes and put \(S=\{p_1,\dots ,p_\ell \}\). Then a rational number z is an S-unit if z can be written as

$$\begin{aligned} z=\pm p_1^{b_1} \cdots p_\ell ^{b_\ell } \end{aligned}$$

with some \(b_1,\dots ,b_\ell \in {\mathbb {Z}}\). Write \(U_S\) for the set of S-units.

Further, for \(\gamma \in {\mathbb {Q}}\), write \(h(\gamma )\) for the maximum of the absolute values of the numerator and the denominator of \(\gamma \). Finally, for a non-zero integer m, let \(\omega (m)\) denote the number of distinct prime divisors of |m|.

Now we can give our results about sums of S-units in the solution sets of generalized Pell equations. In the particular case of ’one-term’ sums, our theorem is effective, that is, we are able to bound all the parameters involved. In the general case, we can bound only the number of solutions.

Theorem 2.1

Use the above notation, and let \(k\ge 1\). Then there are at most \(c_1\) tuples \(\left( z_1,\ldots ,z_k\right) \in U_S^k\) such that

$$\begin{aligned} z_{i_1}+\cdots +z_{i_j}\ne 0 \end{aligned}$$
(3)

for any \(0<j\le k\) and \(1\le i_1<\cdots <i_j\le k\), and

$$\begin{aligned} z_1+\cdots +z_k \in X \cup Y, \end{aligned}$$
(4)

where \(c_1\) is an effectively computable constant depending only on \(\omega (t)\), k, and \(\ell \). Further, if \(k=1\), then we also have

$$\begin{aligned} h(z_1)<c_2, \end{aligned}$$

where \(c_2\) is an effectively computable constant depending only on d, t, and S.

Remark

Schinzel [13] proved that the greatest prime divisor of f(x), where f is a quadratic polynomial with integer coefficients having distinct roots, effectively tends to infinity as \(|x|\rightarrow \infty \). From this, the case \(k=1\) of the above theorem easily follows. However, to keep the presentation coherent, we shall give a general proof of Theorem 2.1, ultimately based upon the theory of S-unit equations.

We also note that the condition (3) is not only natural, but it is necessary, as well. Indeed, if for some \(z_1,\dots ,z_k\), we have (4), but (3) does not hold for some \(0<j\le k\) and \(1\le i_1<\cdots <i_j\le k\), then the sums

$$\begin{aligned} z_1+\cdots +z_k+(z_0-1)(z_{i_1}+\cdots +z_{i_j})\quad (z_0\in U_S) \end{aligned}$$

would yield infinitely many solutions for the inclusion (4).

3 The proof of Theorem 2.1

To prove our theorem, we need several lemmas. The first one describes the solutions of Eq. (2) in the particular, but very important case \(t=1\).

Lemma 3.1

Let \(u_0\) and \(v_0\) be the smallest positive solutions (in x and y, respectively) of the equation

$$\begin{aligned} x^2-dy^2=1. \end{aligned}$$
(5)

Then all positive integer solutions uv of (5) are given by

$$\begin{aligned} u+\sqrt{d}v=\left( u_0+\sqrt{d}v_0\right) ^m\quad (m\ge 1). \end{aligned}$$

Proof

The statement is [12, Theorem 7.26, p. 354]. \(\square \)

Before formulating our further lemmas, we need to introduce some notation concerning recurrence sequences. Let AB be integers with \(B\ne 0\), and let \(U_0,U_1\) be integers such that at least one of them is non-zero. Then the sequence \(U=(U_{n})_{n \ge 0}\) satisfying the relation

$$\begin{aligned} U_n=AU_{n-1}+BU_{n-2}\quad (n\ge 2) \end{aligned}$$
(6)

is called a binary linear recurrence sequence. We shall also use the notation \(U=U(A,B,U_0,U_1)\) for the sequence. The characteristic polynomial of U is defined by

$$\begin{aligned} f(x):=x^2-Ax-B. \end{aligned}$$

Write \(\alpha \) and \(\beta \) for the roots of f(x). The sequence U is called degenerate if \(\alpha /\beta \) is a root of unity; otherwise it is called non-degenerate. It is well-known that if U is non-degenerate, then we have

$$\begin{aligned} U_n=\frac{(U_1-U_0\beta )\alpha ^n-(U_1-U_0\alpha )\beta ^n}{\alpha -\beta }\ \ \ (n\ge 0). \end{aligned}$$
(7)

Our second lemma shows that the sets of the coordinates of the solutions of Eq. (2) are unions of finitely many non-degenerate binary linear recurrence sequences. We note that this assertion is long and well-known qualitatively. However, we do not know any source where this statement is explicitly formulated (let alone the paper of Liptai [10] which is in Hungarian). In fact, we shall only need the case concerning solutions with \(\gcd (x,y)=1\). However, we find the general case of possible independent interest. For a non-negative integer m, write \(\tau (m)\) for the number of divisors of |m|.

Lemma 3.2

Let \(u_0\) be as in Lemma 3.1. If Eq. (2) has a solution, then all its solutions are given by

$$\begin{aligned} (x,y)=\left( G_n^{(i)},H_n^{(i)}\right) \ \ \ (i=1,\dots ,I) \end{aligned}$$

with some binary recurrence sequences

$$\begin{aligned} G^{(i)}=G^{(i)}(2u_0,-1,G_0^{(i)},G_1^{(i)}),\quad H^{(i)}=H^{(i)}(2u_0,-1,H_0^{(i)},H_1^{(i)}). \end{aligned}$$

Here I and \(G_0^{(i)},G_1^{(i)},H_0^{(i)},H_1^{(i)}\)\((i=1,\dots ,I)\) are some positive integers with \(I<c_3\) and

$$\begin{aligned} |G_j^{(i)}|,|H_j^{(i)}|<c_4\ (0\le j\le 1,\ 1\le i\le I), \end{aligned}$$
(8)

where \(c_3\) is an effectively computable constant depending only on \(\tau (t)\), while \(c_4\) is an effectively computable constant depending only on d and t. Further, for the solutions (xy) of (2) with \(\gcd (x,y)=1\), the same conclusion holds with \(I<c_5\) and (8), where \(c_5\) is an effectively computable constant depending only on \(\omega (t)\).

Proof

Obviously, we may restrict to positive integer solutions of (2). So let (pq) be a positive solution of (2). Then the norm \(N(p+\sqrt{d}q)\) of the algebraic integer \(p+\sqrt{d}q\) is t in the field \({\mathbb {Q}}(\sqrt{d})\). By [9, Lemma 5], we know that there are only finitely many pairwise non-associate algebraic integers \(U+V\sqrt{d}\) in \({\mathbb {Q}}(\sqrt{d})\) of norm t, and their number I can be bounded in terms of \(\tau (t)\); further, under the assumption \(\gcd (p,q)=1\), even in terms of \(\omega (t)\). It is well-known (see, e.g., [14, Chapter A]) that we may assume here that

$$\begin{aligned} \max (|U|,|V|)<c_6, \end{aligned}$$

where \(c_6\) is an effectively computable constant depending only on dt. Thus there exist algebraic integers \(U_i+\sqrt{d}V_i\) with \(N(U_i+\sqrt{d}V_i)=t\) and \(\max (|U_i|,|V_i|)<c_6\)\((i=1,\dots ,I)\) such that

$$\begin{aligned} p+\sqrt{d}q=\nu (U_i+\sqrt{d}V_i) \end{aligned}$$

for some \(1\le i\le I\), where \(\nu \) is a unit in \({\mathbb {Q}}(\sqrt{d})\). We immediately get that \(N(\nu )=1\). Thus Lemma 3.1 yields that

$$\begin{aligned} \nu =\pm (u_0+\sqrt{d}v_0)^z \, \, (z \in {\mathbb {Z}}). \end{aligned}$$

For simplicity, we assume that \(\nu =(u_0+\sqrt{d}v_0)^m\) with some \(m\ge 0\) since all the other cases are similar (or can be excluded by our assumption that p and q are positive). Then we have

$$\begin{aligned} p+\sqrt{d}q=(U_i+\sqrt{d}V_i)(u_0+\sqrt{d}v_0)^m, \end{aligned}$$

whence also

$$\begin{aligned} p-\sqrt{d}q=(U_i-\sqrt{d}V_i)(u_0-\sqrt{d}v_0)^m. \end{aligned}$$

Putting

$$\begin{aligned} \alpha :=u_0+\sqrt{d}v_0,\ \ \ \beta :=u_0-\sqrt{d}v_0, \end{aligned}$$

from these assertions, we obtain

$$\begin{aligned} p=\frac{U_i+\sqrt{d}V_i}{2}\alpha ^m+\frac{U_i-\sqrt{d}V_i}{2}\beta ^m \end{aligned}$$

and

$$\begin{aligned} q=\frac{U_i+\sqrt{d}V_i}{2\sqrt{d}}\alpha ^m-\frac{U_i-\sqrt{d}V_i}{2\sqrt{d}}\beta ^m. \end{aligned}$$

Hence, as \(\alpha ,\beta \) are roots of the polynomial \(x^2-2u_0x+1\) (also in view of (7)), we get that p and q are elements of the recurrence sequences \(G=G(A,B,G_0^{(i)},G_1^{(i)})\) and \(H=H(A,B,H_0^{(i)},H_1^{(i)})\), respectively, with

$$\begin{aligned} A=2u_0,\quad B=-1, \end{aligned}$$

and

$$\begin{aligned} (G_0^{(i)},G_1^{(i)})=(U_i,u_0U_i+dv_0V_i),\quad (H_0^{(i)},H_1^{(i)})=(V_i,v_0U_i+2u_0V_i). \end{aligned}$$

Finally, note that it is obvious that the terms of these recurrence sequences are solutions of (2). Hence our claim follows. \(\square \)

We shall also need a recent finiteness result of Bérczes et al. [2] concerning the number of terms of recurrence sequences representable as k-term sums of S-units.

Lemma 3.3

Let \(U_n\) be a non-degenerate binary linear recurrence sequence as in (6), and suppose that the characteristic polynomial of \(U_n\) has irrational roots. Then for any fixed \(k\ge 1\), Eq. (1) is solvable in \(z_1,\dots ,z_k\in U_S\) at most for finitely many n. Further, the number of indices n for which (1) is solvable for this fixed k, can be bounded by an effectively computable constant depending only on \(\ell \) and k.

Proof

The statement is a simple consequence of [2, Theorem 1] and its proof. Note that the statement in [2] concerns only the case where \(z_1,\dots ,z_k\in U_S\cap {\mathbb {Z}}\), however, from the proof it is clear that this more general formulation is also valid. \(\square \)

Our last lemma is a deep result concerning the finiteness of the solutions of S-unit equations. For its formulation, we need to introduce some further notation.

Let \({\mathbb {K}}\) be an algebraic number field, and let \({\mathcal {S}}=\{P_1,\dots ,P_\ell \}\) be a finite set of prime ideals of \({\mathbb {K}}\). Write \(U_{\mathcal {S}}\) for the \({\mathcal {S}}\)-units in \({\mathbb {K}}\), that is, for the set of those \(\alpha \in {\mathbb {K}}\) for which the principal fractional ideal \((\alpha )\) can be represented as

$$\begin{aligned} (\alpha )=P_1^{b_1}\cdots P_\ell ^{b_\ell }\ \ \ (b_1,\ldots ,b_\ell \in {\mathbb {Z}}). \end{aligned}$$

By the (naive) height \(h(\gamma )\) of an element \(\gamma \in {\mathbb {K}}\) we mean the maximum of the absolute values of the coefficients of the defining primitive polynomial of \(\gamma \) in \({\mathbb {Z}}[x]\). Note that for \(\gamma \in {\mathbb {Q}}\), \(h(\gamma )\) is just the maximum of the absolute values of the numerator and denominator of \(\gamma \).

Lemma 3.4

Use the above notation, and let \(a_1,\dots ,a_k\) be non-zero elements of \({\mathbb {K}}\). Then the equation

$$\begin{aligned} a_1x_1+\cdots +a_kx_k=1 \end{aligned}$$
(9)

has at most \(c_7\) solutions \((x_1,\dots ,x_k)\in U_{\mathcal {S}}^k\) for which the left hand side of (9) has no vanishing subsums. Here \(c_7\) is an effectively computable constant depending only on \(k,\ell \), and \(\deg {\mathbb {K}}\).

Further, if \(k=2\), then we also have \(\max (h(x_1),h(x_2))<c_8\), where \(c_8\) is an effectively computable constant depending only on \(a_1,a_2,{\mathbb {K}},{\mathcal {S}}\).

Proof

The statement follows from [7, Theorem 6.1.3, p. 132] and [7, Corollary 4.1.5, p. 65]. For the history of the equation and for related results, see [7]. \(\square \)

Now we are ready to give the proof of Theorem 2.1.

Proof of Theorem 2.1

Let \(z_1,\dots ,z_k\in U_S\) satisfy (4) and (3). Assume first that

$$\begin{aligned} z_1+\cdots +z_k\in X. \end{aligned}$$

Let (pq) be a solution of (2) such that

$$\begin{aligned} z_1+\cdots +z_k=p, \end{aligned}$$

and write \(z=\gcd (p,q)\). Observe that \(z\mid t\). By Lemma 3.2, we have that

$$\begin{aligned} z_1+\cdots +z_k=zG_n^{(i)} \end{aligned}$$
(10)

with some \(i\in \{1,\dots ,I\}\) and \(n\ge 0\), where I is bounded in terms of \(\omega (t)\) and \(G_n^{(i)}\) is a term of a non-degenerate binary recurrence sequence \(G^{(i)}=G^{(i)}(2u_0,-1,G_0^{(i)},G_1^{(i)})\). Note that as \(v_0>0\) (in Lemma 3.1), we have \(u_0>1\). Thus the roots \(\alpha \) and \(\beta \) of the characteristic polynomial

$$\begin{aligned} f(x)=x^2-2u_0+1 \end{aligned}$$

are (real) irrational numbers. (Observe that here f(x), hence \(\alpha \) and \(\beta \) are independent of i.) We can rewrite (10) as

$$\begin{aligned} z^{-1}z_1+\cdots +z^{-1}z_k=G_n^{(i)}, \end{aligned}$$

and observe that here \(w_j:=z^{-1}z_j\)\((j=1,\dots ,k)\) is an \(S^*\)-unit, where

$$\begin{aligned} S^*=S\cup \{p\ \text {prime}:p\mid t\}. \end{aligned}$$

Thus by Lemma 3.3, we see that the number of possible indices n in (10) is bounded by a constant \(c_9\) depending only on \(\ell \), \(\omega (t)\), and k. Further, by (3), \(G_n^{(i)}\ne 0\) in (10). Thus setting \(a_j=1/G_n^{(i)}\) for \(j=1,\dots ,k\), Eq. (10) can be rewritten as

$$\begin{aligned} a_1w_1+\cdots +a_kw_k=1. \end{aligned}$$

Hence in view of (3), and as the number of the above type equations appearing is at most \(c_9\), our statement concerning the number of solutions to (4) follows by Lemma 3.4. Further, in the particular case \(k=1\), Eq. (10) reduces to

$$\begin{aligned} w_1=G_n^{(i)}, \end{aligned}$$
(11)

which in view of Lemma 3.2 and (7) can be rewritten as

$$\begin{aligned} a_i\frac{\alpha ^n}{w_1}+b_i\frac{\beta ^n}{w_1}=1 \end{aligned}$$

with some \(a_i,b_i\) depending only on dt, where

$$\begin{aligned} \alpha =u_0+\sqrt{d}v_0,\ \ \ \beta =u_0-\sqrt{d}v_0. \end{aligned}$$

Let

$$\begin{aligned} {\mathcal {S}}=\bigcup _{p \in S^*}\{ P : P\ \text {is a prime ideal in}\ {\mathbb {Q}}(\sqrt{d}),\ P \vert (p) \}. \end{aligned}$$

As \(\alpha \) and \(\beta \) are roots of the polynomial \(x^2-2u_0x+1\), they are units in \({\mathbb {Q}}(\sqrt{d})\), so \(\alpha ,\beta \in U_{{\mathcal {S}}}\). Thus by Lemma 3.4, we obtain that for some \((\gamma _1,\gamma _2) \in U_{{\mathcal {S}}} \times U_{{\mathcal {S}}}\) with \(\max (h(\gamma _1),h(\gamma _2))<c_{10}\), where \(c_{10}\) is a constant depending only on dt, and S, we have

$$\begin{aligned} \frac{\alpha ^n}{w_1}=\gamma _1,\ \ \ \frac{\beta ^n}{w_1}=\gamma _2. \end{aligned}$$

By multiplying these expressions, in view of \(\alpha \beta =1\), we obtain

$$\begin{aligned} w_1^2=\frac{1}{\gamma _1\gamma _2}, \end{aligned}$$

whence we can bound \(h(z_1)\) in terms of dt, and S. Hence in this case, our claim follows also for \(k=1\).

Let now

$$\begin{aligned} z_1+\cdots +z_k\in Y. \end{aligned}$$

In this case, a similar argument applies, using the sequences \(H^{(i)}\) in place of the sequences \(G^{(i)}\). Thus we omit the details, and the proof of the theorem is complete. \(\square \)

Remark

In case of \(t\in \{\pm 1,\pm 4\}\), one can easily check that the sequences \(G^{(i)}\) and \(H^{(i)}\) are Lucas-sequences of the first and second kind, respectively. Hence in this case, for \(k=1\), in (11) (or in the equation \(w_1=H_n^{(i)}\) when \(z_1\in Y\)), one can get a very good bound for n, using the famous result of Bilu, Hanrot, and Voutier [3] concerning the existence of primitive prime divisors of the terms of such sequences.