1 Introduction

In the 1930s, Pillai (see [20, 21]) conjectured that for any given integer \(c\ge 1\), the number of positive integer solutions (abxy), with \(x, y\ge 2\) to the equation

$$\begin{aligned} a^{x}-b^{y}=c, \end{aligned}$$
(1)

where c is a fixed positive integer is finite. This conjecture is still open for all \( c\ne 1 \). The case \( c=1 \), the so-called Catalan’s conjecture was proved by Mihăilescu (see [19]). Pillai studied the case that a and b are fixed. Let us note that this is an extension of the work of Herschfeld (see [15, 16]), who had already studied the particular case that \((a,b)=(2,3)\). Since then, numerous variations of the Pillai equation have been studied. Some recent results of such variations of Pillai’s problem involving Fibonacci numbers, Tribonacci numbers, Pell numbers, the k-generalized Fibonacci numbers and other generalized linearly recurrent sequences, have been studied, for example, in [2,3,4,5,6,7,8,9, 13, 14].

In [12], Gúzman Sánchez and the second author studied the problem of representing a term of a binary linear recurrent sequence \(\{u_n\}\) as a linear combination of a factorial and an S-unit, in particular they studied the Diophantine equation

$$\begin{aligned} u_n=s+m!, \end{aligned}$$

where s is some S-unit for a fixed set of primes S. In fact, they proved that this equation has only finitely many solutions, which are all effectively computable. This problem has been recently revisited in [17] where the case of Cullen or Woodall numbers has been considered.

In this paper, we study the hybrid problem of representing integers as difference between a factorial and an S-unit. Therefore let S be a finite set of primes. Then the set \(\mathbb {Z}_S\) of S-units consists of all integers whose prime divisors lie all within the set S. We consider for a fixed integer c the Diophantine equation

$$\begin{aligned} c= s-n! \end{aligned}$$
(2)

with \((s,n)\in \mathbb {Z}_S\times \mathbb {N}^+\) (we denote by \(\mathbb {N}^+\) the set of positive integers). In particular, we are interested in finding those integers c admitting at least two solutions \((s_1,n_1)\) and \((s_2,n_2)\) to (2). This is a variation of Pillai’s equation (1).

In order to find all integers c such that (2) has at least two solutions we consider the Diophantine equation

$$\begin{aligned} s_1-n_1!=c= s_2-n_2!, \end{aligned}$$
(3)

with \((s_1,s_2,n_1,n_2)\in \mathbb {Z}_S\times \mathbb {Z}_S \times \mathbb {N}^+ \times \mathbb {N}^+\). We call a solution to (3) with \(s_1=s_2\) and \(n_1=n_2\) trivial. In order to avoid trivial solutions we assume from now on that \(n_2>n_1\).

Let us also introduce the following notation to avoid technical difficulties stating our results. We write for any real number \(x\ge 1\)

$$\begin{aligned} \log ^+ x:=\max \{1,\log x\}. \end{aligned}$$

Our main result is that there are only finitely many non-trivial solutions to (3) all of which are effectively computable. In particular, we prove the following theorem:

Theorem 1

Let \(S=\{p_1,\ldots ,p_k\}\) be a finite set of primes with \(p_1< \cdots <p_k\) and \(\mathbb {Z}_S\) the corresponding set of S-units and choose \(P=\max \{5,p_k\}\). Assume that \((s_1,s_2,n_1,n_2)\) is a solution to (3) with \(n_2>n_1\), and

$$\begin{aligned} s_1=p_1^{a_1}\cdots p_k^{a_k}\quad \text {and} \quad s_2=p_1^{b_1}\cdots p_k^{b_k} \end{aligned}$$

and let \(d:=\max \{a_i,b_i\,\, 1\le i\le k \}\). Then all non-trivial solutions to Diophantine equation (3) satisfy

$$\begin{aligned} d<C_d(k,P),\qquad n_1<C_{n_1}(k,P), \qquad n_2<C_{n_2}(k,P), \end{aligned}$$

where \(C_d(k,P),C_{n_1}(k,P)\) and \(C_{n_2}(k,P)\) are effectively computable.

Let us note that the special case that \(k=1\) and \(p_1=2\) has been resolved by Elsholtz et.al. [11, Theorem 7]. An explicit description how to compute \(C_d(k,P)\), \(C_{n_1}(k,P)\) and \(C_{n_2}(k,P)\) is given by Lemma 7.

Although the bound for d implied by Theorem 1 is quite large and a brute force search is in practice unfeasible it is possible to use approximation lattices to reduce these huge bounds for a concrete choice of the set of primes S. Taking \(S=\{2,3,5,7\}\) we can prove the following numerical result.

Theorem 2

Let \(S=\{2,3,5,7\}\) and \(\mathbb {Z}_S\) be its corresponding set of S-units. Then, there exist exactly 1080 integers c such that

$$\begin{aligned} c=s_1-n_1!=s_2-n_2!, \end{aligned}$$

where \(s_1,s_2\in \mathbb {Z}_S\) and \(n_2>n_1>0\) are integers. In all instances we have

$$\begin{aligned} - 35156063457607680000\le c\le 284856907603968000, \end{aligned}$$

and \(n_2\le 22\) and \(d\le 28\).

In particular, the Diophantine equation (2) has for \(c\ne 0\) at most six solutions. Moreover, (2) has

  • exactly ten solutions if and only if \(c=0\),

  • exactly six solutions if and only if \(c=48\),

  • exactly five solutions if and only if \(c=6,8,30,4680,5760\),

  • exactly four solutions if and only if

    $$\begin{aligned} c= & {} 1, 3, 4, 15, 24, 26, 80, 120, 144, 360, 480, 624,\\{} & {} 840, 1680, 45360, 47880, 241920 \end{aligned}$$
  • and provided that \(c<0\) it has exactly three solutions if and only if

    $$\begin{aligned} c=-20,- 630, -4480, -226800, -1170505728000. \end{aligned}$$

We refrain from listing all integers c and all solutions to (3) in the case that \(S=\{2,3,5,7\}\).

The rest of the paper is organized as follows. In Sect. 2, we state lower bounds for linear forms in complex and p-adic logarithms which are important for our argument. Moreover, we explain how approximation lattices in combination with LLL-latices can reduce our initial bounds. In Sect. 3, we give the proof of Theorem 1. In Sect. 4, we show how to reduce the huge initial bounds for \(n_1,n_2\) and d given by Theorem 1 to small bounds by using approximation lattices. A tricky computer search allows us to find all solutions to (3). This computer search is explained in detail in Sect. 5.

2 Results from Diophantine approximation

To prove our main result Theorem 1, we use several times a Baker-type lower bound for a non-zero linear form in logarithms of algebraic numbers. There are many such bounds in the literature like that of Baker and Wüstholz from [1]. In this paper we use the result of Matveev [18], which is one of our main tools.

We start by recalling some basic notions from height theory. Let \( \gamma \) be an algebraic number of degree d with minimal primitive polynomial over the integers

$$\begin{aligned} a_{0}x^{d}+ a_{1}x^{d-1}+\cdots +a_{d} = a_{0}\prod _{i=1}^{d}(x-\gamma ^{(i)}), \end{aligned}$$

where the leading coefficient \( a_{0} \) is positive and the \( \gamma ^{(i)} \)’s are the conjugates of \( \gamma \). Then the logarithmic height of \( \gamma \) is given by

$$\begin{aligned} h(\gamma ):= \frac{1}{d}\left( \log a_{0} + \sum _{i=1}^{d}\log \left( \max \{|\gamma ^{(i)}|, 1\}\right) \right) . \end{aligned}$$

In particular, if \( \gamma = p/q \) is a rational number with \( \gcd (p,q) = 1 \) and \( q\ge 1 \), then \( h(\gamma ) = \log \left( \max \{|p|, q\}\right) \). The following are some of the properties of the logarithmic height function \( h(\cdot ) \), which will be used in the next sections of this paper without further reference:

$$\begin{aligned} h(\eta \pm \gamma )&\le h(\eta ) +h(\gamma ) +\log 2,\\ h(\eta \gamma ^{\pm 1})&\le h(\eta ) + h(\gamma ),\\ h(\eta ^{s})&= |s|h(\eta ) \qquad (s\in \mathbb {Z}). \end{aligned}$$

Theorem 3

(Matveev) Let \(\gamma _1,\ldots ,\gamma _t\) be positive real algebraic numbers in a real algebraic number field \(\mathbb {K}\) of degree D, \(e_1,\ldots ,e_t\) be nonzero integers, and assume that

$$\begin{aligned} \Lambda :=\gamma _1^{e_1} \cdots \gamma _t^{e_t} - 1, \end{aligned}$$
(4)

is nonzero. Then,

$$\begin{aligned} \log |\Lambda | > -1.4\times 30^{t+3}\times t^{4.5}\times D^{2}(1+\log D)(1+\log B)A_1 \ldots A_t, \end{aligned}$$

where

$$\begin{aligned} B\ge \max \{|e_1|, \ldots , |e_t|\}, \end{aligned}$$

and

$$\begin{aligned} A _i \ge \max \{Dh(\gamma _i), |\log \gamma _i|, 0.16\},\qquad {\text {for all}}\qquad i=1,\ldots ,t. \end{aligned}$$

A p-adic analogue of Matveev’s theorem is due to K. Yu [23]. Although Yu’s result holds for arbitrary number fields we only need the following rational version of Yu’s result. Therefore, let us denote by \(\nu _p(\cdot )\) the standard p-adic valuation on the rational field \(\mathbb {Q}\).

Theorem 4

(Yu) Let \(\gamma _1,\ldots ,\gamma _t\) be nonzero rational numbers and \(b_1,\ldots ,b_n\) nonzero integers, and assume that

$$\begin{aligned} \Lambda =\gamma _1^{e_1}\ldots \gamma _t^{e_t}-1 \end{aligned}$$

is nonzero. Then we have

$$\begin{aligned} \nu _{{\mathfrak {p}}}(\Lambda )\le 19(20\sqrt{t+1})^{2(t+1)}\cdot \frac{p}{(\log p)^2}\log (e^5t)H_1 \ldots H_t\log B, \end{aligned}$$
(5)

where \(B\ge 3\) is a number such that \(|e_i|\le B\) for \(1\le i\le t\) and

$$\begin{aligned} H_i\ge \max \{h(\gamma _i),\log p\} \quad \quad \hbox {for } i=1,\ldots ,t. \end{aligned}$$

The following lemma is also useful which is Lemma 7 in [12].

Lemma 1

(Gúzman Sánchez, Luca) If \(m\geqslant 1\), \(Y>(4m^2)^m\) and \(Y>x/(\log x)^m\), then

$$\begin{aligned} x<2^mY(\log Y)^m. \end{aligned}$$

Let \(\mathcal {L}\subseteq \mathbb {R}^k\) be a k-dimensional lattice with LLL-reduced basis \(v_1,\ldots ,v_k\) and denote by B be the matrix with columns \(v_1,\ldots , v_k\). Moreover, we denote by \(v^*_1,\ldots ,v^*_k\) the orthogonal basis of \(\mathbb {R}^k\) which we obtain by applying the Gram-Schmidt process to the basis \(v_1,\ldots ,v_k\). In particular, we have that

$$\begin{aligned} v^*_i=v_i-\sum _{j=1}^{i-1}\mu _{i,j}v^*_j, \qquad \mu _{i,j}=\frac{\langle v_i,v_j\rangle }{\langle v_j^*,v_j^*\rangle }. \end{aligned}$$

Further, let us define

$$\begin{aligned} l(\mathcal {L},y)={\left\{ \begin{array}{ll} \min _{x \in \mathcal {L}} \Vert x-y\Vert , &{} y \not \in \mathcal {L}\\ \min _{0 \ne x \in \mathcal {L}} \Vert y\Vert , &{} y \in \mathcal {L}, \end{array}\right. } \end{aligned}$$

where \(\Vert \cdot \Vert \) denotes the Euclidean norm on \(\mathbb {R}^k\). It is well known, that by applying the LLL-algorithm it is possible to give in polynomial time a lower bound \(c_1\) for \(l(\mathcal {L},y)\) (see e.g. [22, Sect. 5.4]):

Lemma 2

Let \(y\in \mathbb {R}^k\), \(z=B^{-1}y\). Furthermore we define

  • If \(y\not \in \mathcal {L}\) let \(i_0\) be the largest index such that \(z_{i_0}\ne 0\) and put \(\sigma =\{z_{i_0}\}\), where \(\{\cdot \}\) denotes the distance to the nearest integer.

  • If \(y\in \mathcal {L}\) we put \(\sigma =1\).

Finally let

$$\begin{aligned} c_2^2=\max _{1\le j\le k}\left\{ \frac{\Vert v_1\Vert ^2}{\Vert v_j^*\Vert ^2} \right\} . \end{aligned}$$

Then, we have

$$\begin{aligned} l(\mathcal {L},y)^2\ge c_2^{-2}\sigma ^2 \Vert v_1\Vert ^2=c_1^2. \end{aligned}$$

In some of our applications we are given real numbers \(\eta _0,\eta _1,\ldots ,\eta _k\) linearly independent over \(\mathbb {Q}\) and two positive constants \({\tilde{c}}_3,{\tilde{c}}_4\) such that

$$\begin{aligned} |\eta _0+x_1\eta _1+\cdots +x_k\eta _k| \le {\tilde{c}}_3\exp (-{\tilde{c}}_4H), \end{aligned}$$
(6)

where the integers \(x_i\) are bounded by \(|x_i| \le X_i\), for given upper bounds \(X_i\) with \(1\le i\le k\). We write \(X_0=\max _{1 \le i \le k}\{X_i\}\). The basic idea in such a situation, due to de Weger [10], is to approximate the linear form (6) by an approximation lattice. Namely, we consider the lattice \(\mathcal {L}\) generated by the columns of the matrix

$$\begin{aligned} \mathcal {A}=\begin{pmatrix} 1 &{} 0 &{} \dots &{} 0 &{} 0 \\ 0 &{} 1 &{} \dots &{} 0 &{} 0 \\ \vdots &{} \vdots &{} \vdots &{} \vdots &{} \vdots \\ 0 &{} 0 &{} \dots &{} 1 &{} 0 \\ \lfloor {{\tilde{C}}\eta _1}\rfloor &{} \lfloor {{\tilde{C}}\eta _2}\rfloor &{} \dots &{} \lfloor {{\tilde{C}}\eta _{k-1}}\rfloor &{} \lfloor {{\tilde{C}}\eta _k}\rfloor \end{pmatrix}, \end{aligned}$$

where \({\tilde{C}}\) is a large constant usually of the size of about \(X_0^k\). Moreover, we denote by \(\lfloor x\rfloor \) the largest integer \(\le x\). Let us assume that we have an LLL-reduced basis \(b_1,\ldots ,b_k\) of \(\mathcal {L}\) and that we have a lower bound \(l(\mathcal {L},y)\ge {\tilde{c}}_1\) with \(y=(0,0,\ldots ,-\lfloor {C\eta _0}\rfloor )\). Note that \({\tilde{c}}_1\) can be computed by using the results of Lemma 2. Then we have with these notations the following lemma (e.g. see [22, Lemma VI.1]):

Lemma 3

Assume that \(S=\sum _{i=1}^{k-1}X_i^2\) and \(T=\frac{1+\sum _{i=1}^k{X_i}}{2}\). If \({\tilde{c}}_1^2 \ge T^2+S\), then inequality (6) implies that we have either \(x_1=x_2=\cdots =x_{k-1}=0\) and \(x_k=-\frac{\lfloor {{\tilde{C}}\eta _0}\rfloor }{\lfloor {{\tilde{C}}\eta _k}\rfloor }\) or

$$\begin{aligned} H \le \frac{1}{{\tilde{c}}_4}\left( \log ({\tilde{C}}{\tilde{c}}_3)-\log \left( \sqrt{{\tilde{c}}_1^2-S}-T\right) \right) . \end{aligned}$$
(7)

In our applications we also have to apply these techniques in a p-adic setting. Therefore, let us introduce p-adic logarithms and p-adic approximation lattices.

For a prime number p denote by \(\mathbb {Q}_p\) the field of p-adic numbers with the standard p-adic valuation \(\nu _p\). Note that \(\mathbb {Q}_p\) is complete with respect to the p-adic norm \(|x|_p:=p^{-\nu _p(x)}\) and there exists a function \(\log _p x\), the so-called p-adic logarithm, defined on all \(\mathbb {Q}_p\) such that \(\log _p(xy) = \log _p x + \log _p y\) and for every \(\xi \in \mathbb {Q}_p\) with \(|\xi - 1|_p < p^{-1/(p-1)}\) the p-adic logarithm is defined by

$$\begin{aligned} \log _p \xi = -\sum _{i=1}^{\infty } \frac{(1-\xi )^i}{i}. \end{aligned}$$

Moreover, we have

$$\begin{aligned} |\log _p \xi |_p = |\xi - 1|_p \end{aligned}$$

or equivalently

$$\begin{aligned} \nu _p (\log _p \xi ) = \nu _p(\xi -1) \end{aligned}$$

provided that \(|\xi - 1|_p < p^{-1/(p-1)}\). Note that in the case that p is an odd prime \(|\xi - 1|_p < p^{-1/(p-1)}\) is equivalent to \(\nu _p(\xi -1)\ge 1\) and \(|\xi - 1|_2 < 2^{-1/(2-1)}\) is equivalent to \(\nu _2(\xi -1)\ge 2\).

In our application we want to find an upper bound B such that

$$\begin{aligned} \nu _p\left( \eta _1^{a_1}\ldots \eta _t^{a_t}-1\right) \le B. \end{aligned}$$

Provided that \(B\ge 1\) if p is odd and \(B\ge 2\) if \(p=2\), this is equivalent to finding an upper bound B such that

$$\begin{aligned} \left| x_1\log _p \eta _1+\cdots +x_t\log _p \eta _t\right| _p\ge p^{-B} \end{aligned}$$

holds for all \(|x_i|\le X_0\), with \((x_1,\ldots ,x_t)\ne (0,\ldots ,0)\), where the bound \(X_0\) is given. In particular, we want to choose B as small as possible. Indeed we are interested not only to bound one linear form in p-adic logarithms, but we want to bound several linear forms of p-adic logarithms simultaneously with different primes p.

Let \(k,t>0\) be fixed integers and assume that for each \(1\le i \le k\) we are given a prime \(p_i\) and \(\eta _{0,i},\ldots ,\eta _{t,i} \in \mathbb {Z}_{p_i}\). Assume that for each \(1\le i \le k\) we are given a positive integer \(u_i\) and additionally assume that \(u_i\ge 2\) in case that \(p_i=2\). Let us denote by \({\bar{\eta }}_{j,i}\) the smallest non-negative integer such that

$$\begin{aligned} {\bar{\eta }}_{j,i}\equiv \eta _{j,i} \mod p_i^{u_i}. \end{aligned}$$

We consider the \(k+t\) dimensional approximation lattice \(\mathcal {L}\) spanned by the columns of the matrix

$$\begin{aligned} {\mathcal {A}}=\begin{pmatrix} 1 &{} 0 &{} \dots &{} 0 &{} 0 &{} \dots &{} 0 \\ 0 &{} 1 &{} \dots &{} 0 &{} 0 &{} \dots &{} 0 \\ \vdots &{} \vdots &{} \ddots &{} \vdots &{} \vdots &{} \ddots &{} \vdots \\ 0 &{} 0 &{} \dots &{} 1 &{} 0 &{} \dots &{} 0 \\ {\bar{\eta }}_{1,1} &{} {\bar{\eta }}_{2,1} &{} \dots &{} {\bar{\eta }}_{t,1} &{} p_1^{u_1} &{} \dots &{} 0\\ \vdots &{} \vdots &{} \ddots &{} \vdots &{} \vdots &{} \ddots &{} \vdots \\ {\bar{\eta }}_{1,k} &{} {\bar{\eta }}_{2,k} &{} \dots &{} {\bar{\eta }}_{t,k} &{} 0 &{} \dots &{} p_k^{u_k}\\ \end{pmatrix}, \end{aligned}$$
(8)

and the vector \(\vec y=(0,\ldots ,0,-{\bar{\eta }}_{0,1},\ldots ,-{\bar{\eta }}_{0,k})^T\). Assume that we have a lower bound \(c_1\) such that \(l(\mathcal {L},y)\ge c_1\). Then the following lemma can be applied (see [22, Lemma VI.3] for the case that \(k=1\)):

Lemma 4

Let us assume that \(c_1>X_0 \sqrt{t}\), then the only solution to the system

$$\begin{aligned} \left| \eta _{0,i}+x_1 \eta _{1,i}+\cdots +x_t \eta _{t,i}\right| _{p_i} \le p^{-u_i} \qquad 1\le i \le k \end{aligned}$$

of inequalities with \(|x_i|\le X_0\), is \(x_1=\cdots =x_t=0\).

Proof

We follow the ideas of the case \(k=1\) proof given in [22, Lemma VI.3]. Assume that the system of inequalities holds for \(x_1,\ldots ,x_t\). Then we have by the definition of \({\bar{\eta }}_{i,j}\) the system of modular equations:

$$\begin{aligned} \eta _{0,i}+x_1 \eta _{1,i}+\cdots +x_t \eta _{t,i}&\equiv \\ {\bar{\eta }}_{0,i}+x_1 {\bar{\eta }}_{1,i}+\cdots +x_t {\bar{\eta }}_{t,i}&\equiv 0 \mod p_i^{u_i}. \end{aligned}$$

Therefore, the numbers

$$\begin{aligned} z_i= \frac{{\bar{\eta }}_{0,i}+x_1 {\bar{\eta }}_{1,i}+\cdots +x_t {\bar{\eta }}_{t,i}}{p_i^{u_i}} \qquad 1\le i \le k \end{aligned}$$

are all integers and

$$\begin{aligned} \vec x={\mathcal {A}} \begin{pmatrix} x_1 \\ \vdots \\ x_t \\ -z_1\\ \vdots \ z_t \end{pmatrix}= \begin{pmatrix} x_1 \\ \vdots \\ x_t \\ -{\bar{\eta }}_{0,1}\\ \vdots \ {\bar{\eta }}_{0,t} \end{pmatrix} \in \mathcal {L}. \end{aligned}$$

By the definition of \(\vec y\) we have

$$\begin{aligned} \vec x-\vec y=\begin{pmatrix} x_1 \\ \vdots \\ x_t \\ 0 \\ \vdots \\ 0 \end{pmatrix}. \end{aligned}$$

If \(\vec x \ne \vec y\), then we have

$$\begin{aligned} t X_0^2 \ge \Vert \vec x-\vec y\Vert ^2 \ge l(\mathcal {L},\vec y)^2\ge c_1^2, \end{aligned}$$

which is a contradiction to our initial assumption that \(c_1>X_0 \sqrt{t}\). Hence, we have \(\vec x = \vec y\), which implies \(x_1=\cdots =x_t=0\). \(\square \)

3 Proof of Theorem 1

In order to avoid trivial solutions we assume that \(s_1\ne s_2\) and \(n_2>n_1\). We rewrite Eq. (3) as

$$\begin{aligned} s_1-s_2 =n_1!-n_2! \ne 0. \end{aligned}$$

We put \(S=\{p_1,\ldots ,p_k\}\) and consider the set

$$\begin{aligned} \mathbb {Z}_S:=\{p_1^{a_1}\ldots p_k^{a_k}\,:\, p_1,\ldots ,p_k\in S, a_1,\ldots ,a_k\in \mathbb {N}\} \end{aligned}$$

of S-units. Let us write

$$\begin{aligned} s_1=p_1^{a_1}\ldots p_k^{a_k}\quad \text {and}\quad s_2=p_1^{b_1}\ldots p_k^{b_k}. \end{aligned}$$

Let \(P=\max \{5,p_k\}\) and \(d=\max _{i=1,\ldots ,k} \{a_i,b_i\}\). Furthermore, let p be the first prime such that \(p\not \in S\). Due to Bertrand’s postulate we have \(p<2P\). Let us also note that in any case we can choose \(p\ne 2\); i.e., \(p\ge 3\).

Let us recall that for every integer \(n\in \mathbb {N}\) we have, provided that \(n\ge p\)

$$\begin{aligned} \nu _p(n!)=\left\lfloor \frac{n}{p}\right\rfloor +\left\lfloor \frac{n}{p^2}\right\rfloor +\cdots \ge \left\lfloor \frac{n}{p}\right\rfloor >\frac{n}{2p}. \end{aligned}$$
(9)

We will also need the finer estimate

$$\begin{aligned} \nu _p(n!)=\left\lfloor \frac{n}{p}\right\rfloor +\left\lfloor \frac{n}{p^2}\right\rfloor +\cdots =\frac{n-s_p(n)}{p-1}, \end{aligned}$$
(10)

where \(s_p(n)\) denotes the sum of digits of the p-adic digit expansion of n. Also, we will frequently use the following obvious estimates:

$$\begin{aligned} n!<n^n \quad \hbox {and}\quad \log n!< n\log n<n^2. \end{aligned}$$
(11)

We divide the proof of our main theorem into three steps:

3.1 Bounding \(n_1\) in terms of d

Let us assume that \(n_1\ge p\), since otherwise we have \(n_1<2P\) and Lemma 5 below will hold trivially. In view of Theorem 1 we may also assume that \(d\ge 3\).

We consider Eq. (3) and obtain by considering p-adic valuations the following inequality

$$\begin{aligned} \nu _p(s_2-s_1)=\nu _p(n_2!-n_1!)=\nu _p\left( n_1!\left( \frac{n_2!}{n_1!}-1\right) \right) \ge \nu _p(n_1!)> \frac{n_1}{2p}, \end{aligned}$$
(12)

where the last inequality follows from (9). On the other-hand, we have that

$$\begin{aligned} \begin{aligned} \nu _p(s_2-s_1)&=\nu _p(p_1^{b_1}\ldots p_k^{b_k} - p_1^{a_1}\ldots p_k^{a_k})\\&= \nu _p(p_1^{b_1-a_1}\ldots p_k^{b_k-a_k}-1). \end{aligned} \end{aligned}$$
(13)

Now, we are entitled to apply Theorem 4 to obtain an upper bound for (13).

In our application, we take \(t=k\) and put

$$\begin{aligned} (p_1,\ldots ,p_k):=(\gamma _1,\ldots ,\gamma _t), \quad \hbox {and}\quad (b_1-a_1,\ldots ,b_k-a_k):=(e_1,\ldots , e_t). \end{aligned}$$

Let

$$\begin{aligned} \Lambda _1=p_1^{b_1-a_1}\ldots p_k^{b_k-a_k}-1. \end{aligned}$$

Then we have \(\Lambda _1\ne 0\) since by our hypothesis \(s_1\ne s_2\). Thus, we have with \(B=d\) the inequality

$$\begin{aligned} \nu _{p}(\Lambda _1)\le 19(20\sqrt{k+1})^{2(k+1)}\frac{p}{(\log p)^2}\log (ke^5)H_1\ldots H_k \log d, \end{aligned}$$
(14)

where

$$\begin{aligned} H_i\ge \max \{h(p_i),\log p\}. \end{aligned}$$

Since \(h(p_i)= \log p_i\) and \(p_i<p<2P\), then we can take \(H_i=\log (2P)\) for \(i=1,\ldots ,k\). Furthermore, inequalities (12) and (14) yield

$$\begin{aligned} n_1&\le 2p \cdot 19(20\sqrt{k+1})^{2(k+1)}\frac{p}{(\log p)^2}\log (ke^5)(\log 2P)^k\log d\\&\le 38 \cdot (20\sqrt{k+1})^{2(k+1)}\left( \frac{p}{\log p}\right) ^2\log (ke^5)(\log 2P)^k\log d. \end{aligned}$$

First, let us note that \(\log (ke^5)=5+\log k\le 6\log ^+k\). Moreover let us note that the function \(f(x)=\frac{x}{\log x}\) is strictly increasing for \(x\ge e\). Therefore, replacing \(\left( \frac{p}{\log p}\right) ^2\) by \(4\left( \frac{P}{\log 2P}\right) ^2\) we obtain

$$\begin{aligned} n_1&\le 912 \cdot (20^2(k+1))^{k+1}\log ^+ k \cdot \log d\left( \frac{P}{\log 2P}\right) ^2(\log 2P)^k\\&\le 912 \cdot (20^2(k+1))^{k+1}\log ^+ k \cdot \log d \cdot P^2(\log 2P)^{k-2}. \end{aligned}$$

We record this as a lemma:

Lemma 5

All solutions to Eq. (3) satisfy \(n_1\le C_1(k,P)\log d\) with

$$\begin{aligned} C_1(k,P):= 912 \cdot (20^2(k+1))^{k+1}\log ^+ k \cdot P^2(\log 2P)^{k-2}. \end{aligned}$$

3.2 Bounding \(n_2\) in terms of k

Let \(q\in S\) be the smallest prime such that

$$\begin{aligned} \max \{\nu _q(s_1),\nu _q(s_2)\}=d. \end{aligned}$$

We can assume that \(\nu _q(n_2)>\nu _q(n_1)\), since \(\nu _q(n_2)=\nu _q(n_1)\) would imply that

$$\begin{aligned} n_2<n_1+q\le C_1(k,P) \log d +P<1.01 C_1(k,P) \log d. \end{aligned}$$

Let us assume for the moment that \(d\le v_q(n_1!)\). This would imply that

$$\begin{aligned} d\le \frac{n_1}{q-1}\le n_1\le C_1(k,P) \log d. \end{aligned}$$

By an application of Lemma 1 we obtain

$$\begin{aligned} d\le 2 C_1(k,P) \log C_1(k,P). \end{aligned}$$

Thus, we may assume that \(d>v_q(n_1!)\). We distinguish now between four cases:

Case 1a::

\(d=\nu _q(s_1)\) and \(\nu _q(s_2+n_1!)< d\);

Case 1b::

\(d=\nu _q(s_1)\) and \(\nu _q(s_2+n_1!)\ge d\);

Case 2a::

\(d=\nu _q(s_2)\) and \(\nu _q(s_1-n_1!)< d\);

Case 2b::

\(d=\nu _q(s_2)\) and \(\nu _q(s_1-n_1!)\ge d\).

Let us note that the Cases 1a and 2a respectively 1b and 2b can be treated similarly. Thus, we will give details only for the cases 1a and 1b.

3.2.1 Case 1a: \(\nu _q(s_2+n_1!)< d\)

In this case we have that

$$\begin{aligned} \nu _q(n_2!)=\nu _q(s_2+n_1!-s_1)=\nu _q(s_2+n_1!). \end{aligned}$$

Furthermore, inequality (9) gives that

$$\begin{aligned} \nu _q(s_2+n_1!)=\nu _q(n_2!)\ge \left\lfloor \frac{n_2}{q} \right\rfloor \ge \frac{n_2}{2q}. \end{aligned}$$
(15)

Now, let us apply Theorem 4 to

$$\begin{aligned} \nu _q(s_2+n_1!)= \nu _q\left( {\mathop {\overbrace{p_1^{b_1}\ldots p_k^{b_k}(-n_1!)^{-1}-1}}\limits ^{:=\Lambda _2}}\right) +\nu _q(n_1!)\le \nu _q(\Lambda _2)+n_1, \end{aligned}$$

with \(t=k+1\) and

$$\begin{aligned} (\gamma _1,\ldots ,\gamma _t)=(p_1,\ldots ,p_k,-n_1!), \quad \text {and}\quad (e_1,\ldots , e_t)=(b_1,\ldots ,b_k,-1). \end{aligned}$$

Let us note that since \(p_1^{b_1} \ldots p_k^{b_k}(-n_1!)^{-1}<0\), we have \(\Lambda _2\ne 0.\) Thus, with \(B=d\) we get

$$\begin{aligned} \nu _{q}(\Lambda _2)\le 19(20\sqrt{k+2})^{2(k+2)}\frac{q}{(\log q)^2}\log ((k+1)e^5)H_1 \ldots H_k H_{k+1} \log d. \end{aligned}$$

However, with \(H_i=\log P,\) for \(i=1,\ldots ,k\) we get

$$\begin{aligned} H_i\ge \max \{h(p_i),\log q\}, \end{aligned}$$

since

$$\begin{aligned} h(p_i)=h(p_i)=\log p_i \end{aligned}$$

and \(p_i,q<P\). Furthermore, we choose \(H_{k+1}=n_1^2\) since we have

$$\begin{aligned} H_{k+1}=n_1^2 \ge \max \{h(n_1!),\log q\}=\max \{\log (n_1!),\log q\}=\log (n_1!) \end{aligned}$$

due to (10). Altogether, we get

$$\begin{aligned} \nu _q(\Lambda _2)\le 19(20\sqrt{k+2})^{2(k+2)}\frac{q}{(\log q)^2}\log ((k+1)e^5)\log d (\log P)^k\cdot n_1^2 \end{aligned}$$
(16)

Therefore, a combination of the inequalities (15), (16) and Lemma 5 yields the following bound for \(n_2\):

$$\begin{aligned} n_2\le & {} 2q\nu _q(n_2!)\le 2q \nu _p(\Lambda _2)+2qn_1\nonumber \\\le & {} 228 \cdot (20^2(k+2))^{k+2}\log ^+ (k+1)\frac{q^2}{(\log q)^2}(\log P)^k \cdot \log d \cdot n_1^2 +2Pn_1\nonumber \\\le & {} 229 \cdot (20^2(k+2))^{k+2}\log ^+ (k+1)\frac{P^2}{(\log P)^2}(\log P)^k \cdot \log d \cdot n_1^2\nonumber \\\le & {} C_2(k,P) (\log d)^3, \end{aligned}$$
(17)

where

$$\begin{aligned} C_2(k,P):= 229 \cdot (20^2(k+2))^{k+2}\log ^+ (k+1) P^2(\log P)^{k-2} \cdot C_1(k,P)^2. \end{aligned}$$
(18)

3.2.2 Case 2a: \(\nu _q(s_1-n_1!)< d\)

This case is almost identical to Case 1a. However, instead of \(\Lambda _2\) we consider

$$\begin{aligned} \Lambda _2'=s_1(n_1!)^{-1}-1=p_1^{a_1} \ldots p_k^{a_k}(n_1!)^{-1}-1. \end{aligned}$$

An application of Yu’s theorem (Theorem 4) yields the same bound for \(n_2\) as in the Case 1a.

3.2.3 Case 1b: \(\nu _q(s_2+n_1!)\ge d\)

In this case, we have that

$$\begin{aligned} d\le \nu _q(s_2-n_1!)=\nu _q(p_1^{b_1} \ldots p_k^{b_k}(n_1!)^{-1}-1) \end{aligned}$$

and by using inequality (16), we obtain similarly as in (17) the upper bound

$$\begin{aligned} d \le C_2(k,P)(\log d)^3. \end{aligned}$$
(19)

But, we also have by Eq. (3) that

$$\begin{aligned} | n_2!-n_1!|=|s_2-s_1|\le s_2\le \left( \prod _{p\in S}p\right) ^d\le P^{kd}. \end{aligned}$$

Moreover, we also have

$$\begin{aligned} | n_2!-n_1!|\ge (n_2-1)!(n_2-1)\ge (n_2-1)!\ge \left( \frac{n_2-1}{e}\right) ^{n_2-1}, \end{aligned}$$

where we used the fact that \(n!\ge \left( \frac{n}{e}\right) ^n\) on the right-side of the above inequality. Hence, we have

$$\begin{aligned} \left( \frac{n_2-1}{e}\right) ^{n_2-1}\le P^{kd}. \end{aligned}$$

Using the above inequality and (19), we get

$$\begin{aligned} (n_2-1)\log \left( \frac{n_2-1}{e}\right) \le \left( \prod _{p\in S}p\right) ^d \le kd\log P\le C_2(k,P)k\log P (\log d)^3. \end{aligned}$$
(20)

Note that \(n_2\le (n_2-1)\log \left( \frac{n_2-1}{e}\right) \) holds for all \(n_2\ge 11\). Therefore, we have

$$\begin{aligned} n_2\le C_2(k,P) k\log P (\log d)^3. \end{aligned}$$
(21)

3.2.4 Case 2b: \(\nu _q(n_1!-s_1)\ge d\)

Since we have the same upper bound for \(\nu _q(n_1!-s_1)\) as for \(\nu _q(n_1!+s_2)\) this case can be resolved as Case 1b and we get the same upper bound (21) for \(n_2\).

We summarise what we have proved so far in the following lemma.

Lemma 6

All solutions of the Eq. (3) satisfy

$$\begin{aligned} n_2\le C_3(k,P)(\log d)^3, \end{aligned}$$

with \(C_3(k,P)=C_2(k,P) k \log P\), where \(C_2(k,P)\) is given by (18).

3.3 Bounding d in terms of k

We rewrite Eq. (3) as

$$\begin{aligned} s_2-s_1=n_2!-n_1!. \end{aligned}$$

Let us assume for the moment that there is a \(q\in S\) such that \(\nu _q(s_1)=d\). Then, we have that

$$\begin{aligned} |s_2s_1^{-1}-1|<\frac{n_2!}{s_1}\le \frac{n_2^{n_2}}{2^d}<\exp (n_2\log n_2-d\log 2). \end{aligned}$$
(22)

Now, we use Matveev’s theorem (Theorem 3) to obtain a lower bound for the left-hand side of the above inequality. Therefore, we put

$$\begin{aligned} \Lambda _3=s_2s_1^{-1}-1=p_1^{b_1-a_1} \ldots p_k^{b_k-a_k}-1. \end{aligned}$$

We apply Theorem 3 with \(t=k\), \((\gamma _1,\ldots , \gamma _k):=(p_1,\ldots , p_k)\), \(e_i:=b_i-a_i\) and \(B=d\). As before, we can choose \(A_i=\log P\ge h(p_i)\) and \(D=1\). Therefore, we have that

$$\begin{aligned} \log |\Lambda _3| > -1.4 \times 30^{k+3} \times k^{4.5} \times (1 + \log d)(\log P)^k. \end{aligned}$$

Comparing this last inequality with (22), we get

$$\begin{aligned} 1.4 \times 30^{k+3} \times k^{4.5} \times (1 + \log d)(\log P)^k > d\log 2-n_2\log n_2. \end{aligned}$$
(23)

Assume next, that we are in the case that there is a \(q\in S\) such that \(\nu _q(s_2)=d\). We consider

$$\begin{aligned} |s_1s_2^{-1}-1|<\frac{n_2!}{s_2}<\exp (n_2\log n_2-d\log 2) \end{aligned}$$

instead and obtain by the same argument inequality (23).

Let us now distinguish between the two following cases:

Case 1::

\(n_2 \log n_2 \le d/3\) and

Case 2::

\(n_2 \log n_2 > d/3\).

3.3.1 Case 1: \(n_2\log n_2\le d/3\)

In this case, we have

$$\begin{aligned} d\log 2 -n_2\log n_2\ge d\log 2-d/3>d/6 \end{aligned}$$

and together with (23) we get by assuming that \(d>3\) the inequality

$$\begin{aligned} \begin{aligned} d&< 8.4 \times 30^{k+3} \times k^{4.5} \times (1 + \log d)(\log P)^k\\&<16.8 \times 30^{k+3} \times k^{4.5} \log d (\log P)^k. \end{aligned} \end{aligned}$$
(24)

Applying Lemma 1 on (23) with the data \(m=1\), \(Y:= 1.4 \times 30^{k+3} \times k^{4.5} (\log P)^k,\) and \(x= d\) leads to

$$\begin{aligned} d<33.6 \times 30^{k+3} \times k^{4.5} (\log P)^k \log \left( 16.8 \times 30^{k+3} \times k^{4.5} (\log P)^k\right) :=C_4(k,P). \end{aligned}$$
(25)

3.3.2 Case 2: \(n_2\log n_2 > d/3\)

Now, we have \(n_2\log n_2> d/3\) and applying Lemma 6, we get

$$\begin{aligned} \frac{d}{3}&<C_3(k,P)(\log d)^3\log \left( C_3(k,P)(\log d)^3\right) \\&=3C_3(k,P)(\log d)^3\log \log d+C_3(k,P)(\log d)^3\log \left( C_3(k,P)\right) \\&<4C_3(k,P)\log \left( C_3(k,P)\right) (\log d)^4. \end{aligned}$$

Therefore, we have due to Lemma 1

$$\begin{aligned} d < 48 \cdot C_3(k,P)\log \left( C_3(k,P)\right) \log \left[ C_3(k,P)\log \left( C_3(k,P)\right) \right] ^4:=C_5(k,P). \end{aligned}$$

In any case we have

$$\begin{aligned} d<C_6(k,P):=\max \{C_4(k,P),C_5(k,P)\}. \end{aligned}$$
(26)

Then, from Lemmas 5, 6 and inequality (26), we obtain the following bound on \(n_1\), \(n_2\) and d which prove Theorem 1.

Lemma 7

Let us define:

$$\begin{aligned} C_1(k,P)&= 912 \cdot (20^2(k+1))^{k+1}\log ^+ k \cdot P^2(\log 2P)^{k-2},\\ C_2(k,P)&= 229 \cdot (20^2(k+2))^{k+2}\log ^+ (k+1) \cdot P^2(\log P)^{k-2} \cdot C_1(k,P)^2,\\ C_3(k,P)&=C_2(k,P) k \log P,\\ C_4(k,P)&=33.6 \times 30^{k+3} \times k^{4.5} (\log P)^k \log \left( 16.8 \times 30^{k+3} \times k^{4.5} (\log P)^k\right) ,\\ C_5(k,P)&=48 \cdot C_3(k,P)\log \left( C_3(k,P)\right) \log \left[ C_3(k,P)\log \left( C_3(k,P)\right) \right] ^4,\\ C_d(k,P)&=\max \{C_4(k,P),C_5(k,P)\},\\ C_{n_1}(k,P)&=C_1(k,P)\log \left( C_d(k,P)\right) , \\ C_{n_2}(k,P)&=C_3(k,P)\left( \log \left( C_d(k,P)\right) \right) ^3. \end{aligned}$$

Then all non-trivial solutions to Eq. (3) satisfy

$$\begin{aligned} d<C_d(k,P),\qquad n_1<C_{n_1}(k,P), \qquad n_2<C_{n_2}(k,P). \end{aligned}$$

4 Reduction of the bounds

Now, we consider the case where \(S=\{2,3,5,7\}\). Using the bounds given in Lemma 7 we obtain the following bounds for \(n_1,n_2\) and d which we record in the following lemma:

Lemma 8

Let \((s_1,s_2,n_1,n_2)\) be a non-trivial solution to (3), where \(S=\{2,3,5,7\}\). Then we have

$$\begin{aligned} d<1.17 \times 10^{83},\qquad n_1<2.641 \times 10^{24}, \qquad n_2<1.357\times 10^{77}. \end{aligned}$$

We want to reduce these huge bounds to much smaller bounds. We do this in three reduction steps:

Step 1: We show that \(n_1\le 2210\):

We consider the main Eq. (3) and rewrite it to

$$\begin{aligned} s_2/s_1-1=n_1! (n_2!/n_1!-1). \end{aligned}$$

Let us assume for the moment that \(n_1\ge 2p_i\) for some prime \(p_i>7\). Then the \(p_i\)-adic absolute value on the right hand side is at most \(p_i^{-2}\). Therefore, we obtain by the properties of the p-adic logarithm the inequality:

$$\begin{aligned}&|(b_1-a_1)\log _{p_i}2+ (b_2-a_2)\log _{p_i}3+ (b_3-a_3)\log _{p_3}5+ (b_4-a_4)\log _{p_i}7|_{p_i}\nonumber \\&\quad =|s_2/s_1-1|_{p_i} \le p_i^{-\nu _{p_i}(n_1!)}. \end{aligned}$$
(27)

Let us consider the p-adic approximation lattice from (8), with

$$\begin{aligned}{} & {} p_1=11,\quad p_2=13,\quad p_3=17,\quad p_4=19,\quad \text {and}\\{} & {} \quad u_1=220, \quad u_2=184,\quad u_3=137,\quad u_4=122. \end{aligned}$$

Moreover, we choose \({\bar{\eta }}_{i,t}\equiv \log _{p_t} {q_i} \mod p_t^{u_t}\), where \(q_1=2\), \(q_2=3\), \(q_3=5\) and \(q_4=7\). With \(X_0\le 1.17 \times 10^{84}\) we obtain \(l(\mathcal {L},y)>5.43\times 10^{94}>2 X_0\), where \(y=(0,\ldots ,0)^T\). That is either

$$\begin{aligned} b_1-a_1=b_2-a_2=b_3-a_3=b_4-a_4=0 \end{aligned}$$

or at least one of the inequalities \(\nu _{p_i}(n_1!)< u_i\) holds due to Lemma 4.

Let us note that due to (10) the inequalities

$$\begin{aligned} \nu _{11}(n_1!)<220,\quad \nu _{13}(n_1!)<184,\quad \nu _{17}(n_1!)<137,\quad \nu _{19}(n_1!)<122 \end{aligned}$$

imply \(n_1\le 2210\), \(n_1\le 2209\), \(n_1\le 2209\) and \(n_1\le 2203\), respectively.

Step 2: Let \(q\in S=\{2,3,5,7\}\) such that \(v_q(s_1)=d\) or \(v_q(s_2)=d\) holds. We show that

  • \(n_2\le 3413\) if \(q=2\);

  • \(n_2\le 3791\) if \(q=3\);

  • \(n_2\le 4364\) if \(q=5\);

  • \(n_2\le 4871\) if \(q=7\).

Let us assume that \(q=2\). We start by showing that in this case we have \(\nu _2(\pm s_i/n_1!-1)\le 1199\) for \(i=1,2\). Assume for the moment that \(n_1\le 10\). Then \(s_i/n_1!\) is a rational number, such that the only prime factors appearing in the numerator or denominator are 2, 3, 5 or 7. We want to find an upper bound for \(v_2(\pm s_i/n_1!-1)\). Let us assume for the moment that \(\nu _2(\pm s_i/n_1!-1)\ge 2\), then we have due to properties of the 2-adic logarithm

$$\begin{aligned} |a'_2 \log _2 3+a'_3\log _2 5+a'_4 \log _2 7|_2=|\nu _2(\pm s_i/n_1!-1)|_2, \end{aligned}$$

where \(s_i/n_1!=3^{a'_2}5^{a'_3}7^{a'_4}\). Note that if in the prime factorization of \(s_i/n_1!\) would appear a 2, we would have \(\nu _2(\pm s_i/n_1!-1)=0\), which contradicts our assumption. We consider now the approximation lattice (8), with \(t=1\), \(p_1=2\), \(u_1=1200\) and \(\eta _{i,1}=\log _2 3\), \(\eta _{i,2}=\log _2 5\) and \(\eta _{i,3}=\log _2 7\). With

$$\begin{aligned} X_0\le 1.17 \times 10^{83}+v_2(n_1!)\le 1.17 \times 10^{83}+8 \end{aligned}$$

and \(y=(0,0,0,0)^T\) the inequality \(l(\mathcal {L},y)>\sqrt{3} X_0\) is satisfied and an application of Lemma 4 yields either \(s_i=n_1!\) or \(\nu _2(\pm s_i/n_1!-1)\le 1199\). Note that \(s_1=n_1!\) implies \(s_2=n_2!\), that is \(n_2!\) has only the prime factors 2, 3, 5 and 7, which implies \(n_2\le 10\). Furthermore \(s_2=n_1!\) implies that \(2s_2-s_1=n_2!\). Now, we can proceed as in Step 1 but consider the inequality

$$\begin{aligned} \begin{aligned} |(b_1-a_1+1)\log _{p_i}2+ (b_2-a_2)\log _{p_i}3+&(b_3-a_3)\log _{p_3}5+ (b_4-a_4)\log _{p_i}7|_{p_i}\\&=|s_2/s_1-1|_{p_i} \le p_i^{-\nu _{p_i}(n_1!)}. \end{aligned} \end{aligned}$$

instead of inequality (27). Hence, we obtain similarly as in Step 1 that \(n_2\le 2210\) by an application of Lemma 4.

Assume next that we are in the case that \(n_1>10\). We consider the approximation lattice (8), with \(t=1\), \(p_1=2\), \(u_1=1200\) and \(\eta _{i,1}=\log _2 3\), \(\eta _{i,2}=\log _2 5\), \(\eta _{i,3}=\log _2 7\) and \(X_0\le 1.17 \times 10^{83}\). For each \(11\le n_1 \le 2210\) we consider the inequality

$$\begin{aligned} |a_2 \log _2 3+a_3\log _2 5+a_4 \log _2 7 -\log _2 (n_1!)|_2=|\pm s_i/n_1!-1|_2\le 2^{-1200}, \end{aligned}$$
(28)

and an application of Lemma 4 with \(y=(0,0,0,\log _2 (n_1!) \mod 2^{1298})^T\) shows that this inequality has at most a solution with \(a_2=a_3=a_4=0\). Computing \(|\log _2 (n_1!)|_2\) for all instances, we indeed have no solution to inequality (28).

Therefore we have shown that \(\nu _2(\pm s_i/n_1!-1)\le 1199\) holds for \(i=1,2\). This bound implies

$$\begin{aligned} \nu _2(s_i\pm n_1!)=\nu _2(\pm s_i/n_1!-1)+\nu _2(n_1!)\le 1199+2206=3405. \end{aligned}$$

According to the various cases that we considered in Subsection 3.2 we have either

$$\begin{aligned} d\le \nu _2(s_i\pm n_1!)\le 3405, \end{aligned}$$

or

$$\begin{aligned} \nu _2(n_2!)=\nu _2(s_i \pm n_1!)\le 3405. \end{aligned}$$

In the latter case we obtain due to (10) the upper bound \(n_2\le 3413\).

Let us assume for the moment that \(d\le 3405\) holds. We consider inequality (20) and obtain in our case the inequality

$$\begin{aligned} (n_2-1)\log (n_2-1)-(n_2-1) \le d \log (2\cdot 3\cdot 5\cdot 7) <18206.902, \end{aligned}$$

which yields \(n_2\le 2646\).

Thus, we obtain that \(n_2\le 3413\), provided that \(q=2\).

Similar computations for \(q=3\), \(q=5\) and \(q=7\) show that \(n_2\le 3791\), \(n_2\le 4364\) and \(n_2\le 4871\) holds, respectively.

Step 3: We show that

  • \(d\le 36088\) if \(q=2\);

  • \(d\le 25586\) if \(q=3\);

  • \(d\le 20425\) if \(q=5\);

  • \(d\le 19091\) if \(q=7\).

We assume that \(q=2\) and reconsider inequality (22) and aim to apply Lemma 3. In particular, we consider the inequality

$$\begin{aligned} \left| x_1\log 2+x_2\log 3+x_3 \log 5+x_4 \log 7 \right| <\frac{n_2!}{q^d}\le \frac{3413!}{2^d}, \end{aligned}$$

where \(|x_i|=|b_i-a_i|\le X_0:=1.17\times 10^{83}\). Thus, we consider the approximation lattice

$$\begin{aligned} \mathcal {A}=\begin{pmatrix} 1 &{} 0 &{} 0 &{} 0 \\ 0 &{} 1 &{} 0 &{} 0 \\ 0 &{} 0 &{} 1 &{} 0 \\ \lfloor {C \log 2}\rfloor &{} \lfloor {C\log 3}\rfloor &{} \lfloor {C\log 5}\rfloor &{} \lfloor {C\log 7}\rfloor \end{pmatrix}, \end{aligned}$$

with \(C=10^{380}\) and \(y=(0,0,0,0)^T\). Moreover, we put \({\tilde{c}}_3=3413!\) and \({\tilde{c}}_4=\log 2\). Thus, an application of Lemma 2 with Lemma 3 yields \(d\le 36088.\)

In the cases that \(q=3\), \(q=5\) and \(q=7\) we obtain similar bounds for d.

Thus, we have found after the three steps the new much smaller upper bounds

$$\begin{aligned} d\le 36088, \qquad n_2\le 4976, \qquad n_1\le 2210. \end{aligned}$$

We can repeat the previously described reduction steps with these bounds inductively and obtain after three more applications of Steps 1–3:

Lemma 9

Let \((s_1,s_2,n_1,n_2)\) be a non-trivial solution to (3), where \(S=\{2,3,5,7\}\). Then we have \(n_1\le 90\) and

  • \(n_2\le 186\), \(d\le 931\) if \(q=2\);

  • \(n_2\le 182\), \(d\le 722\) if \(q=3\);

  • \(n_2\le 204\), \(d\le 565\) if \(q=5\);

  • \(n_2\le 230\), \(d\le 539\) if \(q=7\).

Let us consider the equation

$$\begin{aligned} s_2s_1^{-1} -1 =\frac{n_1!-n_2!}{s_1}. \end{aligned}$$

Let \(p\not \in S\) be a prime and assume that

$$\begin{aligned} 1<u_p\le \nu _p(n_1!)\le \nu _p\left( n_1!\frac{1-n_2! / n_1!}{s_1}\right) =\nu _p(s_2s_1^{-1}-1) \end{aligned}$$

holds for some integer \(u_p\). Then by taking p-adic logarithms we obtain

$$\begin{aligned} \left| x_1 \log _p 2+ x_2 \log _p 3+x_3 \log _p 5+x_4\log _p 7\right| _p\le p^{-u_p}, \end{aligned}$$
(29)

where \(|x_i|=|b_i-a_i|\le 931\). Taking p-adic logarithms we obtain

$$\begin{aligned} x_1 \eta _{2,p}+x_2 \eta _{3,p}+x_3\eta _{5,p}+x_4\eta _{7,p} \equiv 0 \mod p^{u_p}, \end{aligned}$$

where we write \(\eta _{q,p}=\log _p q \mod p^{u_p}\).

We consider the primes \(p=11,13,17\) and \(p=19\) and choose \(u_{11}=4\), \(u_{13}=4\), \(u_{17}=3\) and \(u_{19}=2\). Considering inequality (29) modulo \(p^{u_p}\) for \(p=11,13,17\) and 19 we obtain the modular linear system

$$\begin{aligned} \begin{aligned} 1881 x_1+\,8833 x_2+\,\,44 x_3+6875 x_4&\equiv 0 \mod 11^4;\\ 28015 x_1+24063 x_2+6409 x_3+5967 x_4&\equiv 0 \mod 13^4;\\ 1802 x_1+\,2720 x_2+2108 x_3+2261 x_4&\equiv 0 \mod 17^3;\\ 304 x_1+\,\,\,19x_2 +\,133 x_3 +\,114 x_4&\equiv 0 \mod 19^2. \end{aligned} \end{aligned}$$
(30)

Let us note that a solution of this linear system does not yield a solution to (3). But on the contrary every solution to (3) with \(\nu _p(n_1!)\ge u_p\) yields a solution to the linear system.

To find all solutions to (30) with \(|x_i|\le 931\) we compute two lists. For \(-931\le x_1,x_2\le 931\) we compute the list List1 consisting of the sixtuples

$$\begin{aligned}{} & {} (1881 x_1+ 8833 x_2 \mod 11^4, 28015 x_1 +24063 x_2 \mod 13^4,\\{} & {} \qquad 1802 x_1+2720 x_2 \mod 17^3, 304x_1+19x_2 \mod 19^2,x_1,x_2) \end{aligned}$$

and the list List2 consisting of the sixtuples

$$\begin{aligned}{} & {} ( -44x_3 -6875 x_4 \mod 11^4, -6409 x_3 -5967 x_4 \mod 13^4,\\{} & {} \qquad -2108 x_3- 2261 x_4 \mod 17^3, -133x_3 - 114x_4 \mod 19^2,x_3,x_4). \end{aligned}$$

If for two entries, one from List1 and one from List2, the first four entries coincide then we have found a solution \((x_1,x_2,x_3,x_4)\) to (30). Constructing these lists and comparing them takes a few minutes on a usual PC. We found 747 possible solutions, but only the trivial solution \(x_1=x_2=x_3=x_4=0\) satisfies

$$\begin{aligned} \nu _p(2^{x_1}3^{x_2}5^{x_3}7^{x_4}-1)\ge u_p \end{aligned}$$

for \(p=11,13,17\) and 19.

Therefore, we have proved that there exists no solution with \(v_{p}(n_1!)\ge u_p\). That is there exists no solution with \(n_1\ge 52\). Therefore we may assume that \(n_1\le 51\). With this new bound for \(n_1\) we can perform the reduction Steps 2 and 3 and obtain \(n_2\le 188\) and \(d\le 655\).

We reconsider the Diophantine inequality (29) for \(p=11,13,17\) and 19 with \(u_{11}=4\), \(u_{13}=3\), \(u_{17}=2\) and \(u_{19}=2\). We get a similar linear system of modular equations as in (30) and find all solutions by computing again two long lists. There are 40669 possible solutions but only the trivial solution \(x_1=x_2=x_3=x_4=0\) satisfies

$$\begin{aligned} \nu _p(2^{x_1}3^{x_2}5^{x_3}7^{x_4}-1)\ge u_p \end{aligned}$$

for \(p=11,13,17\) and 19 and additionally

$$\begin{aligned} \nu _{23}(2^{x_1}3^{x_2}5^{x_3}7^{x_4}-1)\ge 1. \end{aligned}$$

Therefore, we may conclude that \(v_{p}(n_1!)\ge u_p\) does not hold; i.e., we have \(n_1\le 43\). The reduction Steps 2 and 3 yield now \(n_2\le 174\) and \(d\le 574\).

Applying a third time the same approach with \(u_{11}=3\), \(u_{13}=3\), \(u_{17}=2\) and \(u_{19}=2\) leads to the following lemma:

Lemma 10

Let \((s_1,s_2,n_1,n_2)\) be a non-trivial solution to (3), with \(S=\{2,3,5,7\}\). Then we have

$$\begin{aligned} d\le 548,\qquad n_1 \le 38, \qquad n_2\le 167. \end{aligned}$$

For some \(p\not \in S\) we consider again the inequality

$$\begin{aligned} \nu _p(n_1!)\le \nu _p\left( n_1!\frac{1-n_2! / n_1!}{s_1}\right) =\nu _p(s_2s_1^{-1}-1)=\nu _p(2^{x_1}3^{x_2}5^{x_3}7^{x_4}-1)\le u_p \end{aligned}$$
(31)

for some integer \(u_p\). That is we consider the modular equation

$$\begin{aligned} 2^{x_1}3^{x_2}5^{x_3}7^{x_4}\equiv 1 \mod p^{u_p}, \end{aligned}$$
(32)

Instead of using p-adic logarithms to resolve this inequality we try to find solutions directly.

That is we choose \(p=11,13,17\) and 19 together with \(u_{11}=3 \), \(u_{13}=2 \), \(u_{17}=2 \) and \(u_{19}=1\). Similar as in the p-adic logarithms approach we compute two lists. For \(-548\le x_1,x_2\le 548\) we compute the list List1 consisting of the sixtuples

$$\begin{aligned}{} & {} (2^{x_1} 3^{x_2} \mod 11^3,2^{x_1} 3^{x_2} \mod 13^2,\\{} & {} \qquad 2^{x_1} 3^{x_2} \mod 17^2, 2^{x_1} 3^{x_2}\mod 19,x_1,x_2) \end{aligned}$$

and the list List2 consisting of the sixtuples

$$\begin{aligned}{} & {} (5^{-x_3} 7^{-x_4} \mod 11^3,5^{-x_3} 7^{-x_4} \mod 13^2,\\{} & {} \qquad 5^{-x_3} 7^{-x_4} \mod 17^2, 5^{-x_3} 7^{-x_4}\mod 19,x_3,x_4). \end{aligned}$$

We compare these lists and if we have found a sixtuple form List1 and a sixtuple form List2 for which the first four entries coincide, then we have found a solution \((x_1,x_2,x_3,x_4)\) to our system of modular equations (32). Indeed we find 3163 solutions, but none of them, except the trivial solution \(x_1=x_2=x_3=x_4=0\), satisfies

$$\begin{aligned} 23\cdot 29\cdot 31 |2^{x_1}3^{x_2}5^{x_3}7^{x_4}-1. \end{aligned}$$

Therefore, we conclude that \(\nu _p(n_1!)<u_p\) for some \(p\in \{11,13,17,19\}\). Thus, we conclude \(n_1\le 33\).

Performing our reduction Steps 2 and 3 with the new upper bound for \(n_1\) we obtain

$$\begin{aligned} n_1\le 33,\qquad n_2\le 146, \qquad d\le 508. \end{aligned}$$

Next, we aim to prove that \(n_1\le 22\). Therefore, we consider inequality (31) with \(p=11\), \(p=13\), \(p=17\) and \(p=19\) again. But, this time we employ the multiplicative modular approach from above with \(u_{11}=2\), \(u_{13}=1 \), \(u_{17}=1 \) and \(u_{19}=1\) instead. Again we dismiss those solutions which do not satisfy

$$\begin{aligned} \nu _{23}(2^{x_1}3^{x_2}5^{x_3}7^{x_4}-1)\ge 1. \end{aligned}$$

This leaves us with a list of 256777 possible solutions \((x_1,x_2,x_3,x_4)\). Let us call this list Solutions. We have to find a way to show that these solutions do not yield a solution to the main Eq. (3). Therefore, we perform for each \(n_1\) and \(n_2\) with \(23\le n_1 \le 33\) and \(n_1<n_2\le 146\) and for each solution \((x_1,x_2,x_3,x_4)\) from the list Solutions the following computations (this takes about 1 h on a usual desktop PC):

  1. (1)

    We compute \(M=n_2!-n_1!\).

  2. (2)

    We compute for each solution \((x_1,x_2,x_3,x_4)\) from the list Solutions the numerator N of \(2^{x_1}3^{x_2}5^{x_3}7^{x_4}-1\).

  3. (3)

    If \(M\not \equiv 0 \mod N\), then we discard the solution.

Besides the trivial solution, we are left with four possible candidates:

$$\begin{aligned} (n_1,n_2,x_1,x_2,x_3,x_4)&=(29,63,32,0,-14,2),(29,63,-32,0,14,-2),\\&\quad (33,66,32,0,-14,2),(33,66,-32,0,14,-2). \end{aligned}$$

We want to exclude the candidate \((n_1,n_2,x_1,x_2,x_3,x_4) =(29,63,32,0,-14,2)\). Therefore, we note

$$\begin{aligned} v_2(63!-29!)=25, \quad v_3(63!-29!)=13,\quad v_5(63!-29!)=6,\quad v_7(63!-29!)=4, \end{aligned}$$

and since \(v_3(2^{32}5^{-14}7^2-1)=2\) we must have

$$\begin{aligned} s_2-s_1=(s_2s_1^{-1}-1)\cdot s_1=(2^{32}5^{-14}7^2-1)\cdot 2^{25}3^{11}5^{20}7^4 =n_2!-n_1!, \end{aligned}$$

since otherwise the p-adic valuation would not coincide on both sides for \(p=2,3,5\) and 7. But, a numerical computation shows that with \(n_2=63\) and \(n_1=29\) this equation does not hold; i.e., this candidate does not yield a solution to (3). By a similar argument the other three candidates can be discarded. Hence, we have \(n_1\le 22\).

With this smaller bound for \(n_1\) we once again carry out the reduction Steps 2 and 3 and obtain

$$\begin{aligned} n_1\le 22,\qquad n_2\le 139,\qquad d\le 419. \end{aligned}$$

More precisely we have the following lemma:

Lemma 11

Let \((s_1,s_2,n_1,n_2)\) be a non-trivial solution to (3), with \(S=\{2,3,5,7\}\). Then we have \(n_1\le 22\) and

  • in the case that \(q=2\), we have \(n_2\le 106\) and \(d\le 419\);

  • in the case that \(q=3\), we have \(n_2\le 83\) and \(d\le 288\);

  • in the case that \(q=5\), we have \(n_2\le 114\) and \(d\le 285\);

  • in the case that \(q=7\), we have \(n_2\le 139\) and \(d\le 298\).

Next, we aim to show that \(n_2\le 48\). Therefore, we consider the four cases discussed in Sect. 3.2:

Case 1a::

\(d=\nu _q(s_1)\) and \(\nu _q(s_2+n_1!)< d\);

Case 1b::

\(d=\nu _q(s_1)\) and \(\nu _q(s_2+n_1!)\ge d\);

Case 2a::

\(d=\nu _q(s_2)\) and \(\nu _q(s_1-n_1!)< d\);

Case 2b::

\(d=\nu _q(s_2)\) and \(\nu _q(s_1-n_1!)\ge d\).

Let us remind the reader that q is chosen such that \(\max \{\nu _q(s_1),\nu _q(s_2)\}=d\). Let us assume for the moment that \(q=7\). We want to show that \(\nu _7(s_2(-n_1!)^{-1}-1)\le 6\) respectively \(\nu _7(s_1(n_1!)^{-1}-1)\le 6\). In the Case 1a (and similarly in the Case 2a) this leads, as it has been shown in Sect. 3.2, to

$$\begin{aligned} \nu _7(n_2!)=\nu _7(s_2(-n_1!)^{-1}-1)+\nu _7(n_1!)\le 6+\nu _7(22!)=9. \end{aligned}$$

Therefore, we obtain \(n_2\le 62\).

In the Case 1b (and similarly in the Case 2b) we would obtain \(d\le 6\) which yields

$$\begin{aligned} (n_2-1)!<n_2!-n_1!=s_2-s_1<(2\cdot 3\cdot 5\cdot 7)^6<8.58\cdot 10^{13}. \end{aligned}$$

This implies \(n_2\le 17\).

To show that indeed \(\nu _7(s_2(-n_1!)^{-1}-1)\le 6\) holds we proceed as follows. First, we note that \(\nu _7((s_2(-n_1!)^{-1}-1)>0\) if and only if \(\nu _7(n_1!)=\nu _7(s_2)\); i.e., the powers of 7 cancel each other out. Similar as above we compute two lists, where List1 consists of all triples of the form

$$\begin{aligned} (2^{x_1} 3^{x_2} \mod 7^7,x_1,x_2) \end{aligned}$$

with \(0\le x_1,x_2\le 298\) and List2 consists of all triples of the form

$$\begin{aligned} (5^{-x_3} (-n_1!)_7 \mod 7^7,x_3,n_1) \end{aligned}$$

with \(0\le x_3\le 298\) and \(1\le n_1\le 22\), where \((n_1!)_7\) denotes the 7-free part of the factorial of \(n_1\); i.e., \((n_1!)_7=\frac{n_1!}{7^{\nu _7(n_1!)}}\). Entries from List1 and List2 whose first entry coincide yield a solution to

$$\begin{aligned} n_1!+2^{x_1} 3^{x_2}5^{x_3}7^{\nu _7(n_1!)}\equiv 0 \mod 7^7. \end{aligned}$$

In particular, we find 865 solutions \((n_1,x_1,x_2,x_3)\). For each solution we compute

$$\begin{aligned} \nu _7(n_1!+2^{x_1} 3^{x_2}5^{x_3}7^{\nu _7(n_1!)}) \end{aligned}$$

and find that

$$\begin{aligned} \nu _7(n_1!+2^{x_1} 3^{x_2}5^{x_3}7^{\nu _7(n_1!)})\le 13, \end{aligned}$$

which implies \(n_2\le 90\) or \(d\le 13\). But since

$$\begin{aligned} (n_2-1)!<n_2!-n_1!=s_2-s_1<s_2\le (2\cdot 3\cdot 5\cdot 7)^{13} \end{aligned}$$

implies \(n_2\le 90\), we may assume that \(n_2\le 90\) holds in Cases 1a and 1b. A similar computation concerning \(\nu _7(s_1(n_1!)^{-1}-1)\) we obtain that \(n_2\le 90\) also holds in the Cases 2a and 2b. We apply reduction Step 3 with this new lower bound for \(n_2\) and find \(d\le 175\).

Once again we compute the lists List1 and List2 consisting of the triples

$$\begin{aligned} (2^{x_1} 3^{x_2} \mod 7^4,x_1,x_2) \end{aligned}$$

and

$$\begin{aligned} (5^{-x_3} (-n_1!)_7 \mod 7^4,x_3,n_1). \end{aligned}$$

By comparing the lists we find a list Solutions of 58277 solutions to

$$\begin{aligned} n_1!+2^{x_1} 3^{x_2}5^{x_3}7^{\nu _7(n_1!)}\equiv 0 \mod 7^4. \end{aligned}$$

For all \(49\le n_2\le 90\) we check for all solutions \((n_1,x_1,x_2,x_3)\) whether the number

$$\begin{aligned} s_1=n_2!-n_1!-2^{x_1}3^{x_2}5^{x_3}7^{\nu _7(n_1!)} \end{aligned}$$

has only 2, 3, 5 or 7 as prime divisors; i.e., yields a solution to (3). However, none of the solutions from Solutions yields a solution to (3). That is \(n_2\le 48\) or \(\nu _7(n_1!-s_1)\le 3\). Note that the later case yields

$$\begin{aligned} \nu _7(n_2!)=\nu _7(s_2(-n_1!)^{-1}-1)+\nu _7(n_1!)\le 3+\nu _7(22!)=6 \end{aligned}$$

and therefore also \(n_2\le 48\) in the Cases 1a and 1b. Similarly, we can show that in the Cases 2a and 2b also \(n_2\le 48\) holds; i.e., in any case we have \(n_2\le 48\). Moreover, by an application of the reduction Step 3 we obtain \(d\le 84\) in the case that \(q=7\).

And in general for \(q=2,~q=3\) and \(q=5\) we proceed similarly. However in the case that \(q=2\) the Cases 1b and 2b yield larger upper bounds for \(n_2\) but much smaller upper bounds for d. Therefore, we obtain:

Lemma 12

Let \((s_1,s_2,n_1,n_2)\) be a non-trivial solution to (3), with \(S=\{2,3,5,7\}\). Then we have \(n_1\le 22\) and

  • in the case that \(q=2\), we have \(n_2\le 33\) and \(d\le 156\) (Cases 1a and 2a) or \(n_2\le 61\) and \(d\le 36\) (Cases 1b and 2b);

  • in the case that \(q=3\), we have \(n_2\le 35\) and \(d\le 105\);

  • in the case that \(q=5\), we have \(n_2\le 39\) and \(d\le 81\);

  • in the case that \(q=7\), we have \(n_2\le 48\) and \(d\le 84\).

Next for all \(0\le x_1,x_2,x_3,x_4\le 36\):

  • We compute \(s_2=2^{x_1}3^{x_2}5^{x_3}7^{x_4}\).

  • We find the smallest zero of \(\Gamma (x)-s_2=0\) numerically and obtain the upper bound \(n_2\le x\) since \((n_2-1)!=\Gamma (n_2)\) and the \(\Gamma \) function is striclty increasing for \(x\ge 0\).

  • If \(x<34\) we continue to the next quadruple \((x_1,x_2,x_3,x_4)\).

  • For all \(34\le n_2\le x\) and all \(1\le n_1\le 22\)

    • we compute \(M=s_2-n_2!+n_1!\).

    • If \(M<0\) we discard this possible solution.

    • We compute \(v_p=\nu _p(M)\) for \(p=2,3,5,7\) and if \(M=2^{v_2}3^{v_3}5^{v_5}7^{v_7}\) we have found a solution to Diophantine equation (3).

However, this computation yields no solution. Thus, we have proved so far

Proposition 1

Let \((s_1,s_2,n_1,n_2)\) be a non-trivial solution to (3), with \(S=\{2,3,5,7\}\). Then we have \(n_1\le 22\) and

  • in the case that \(q=2\), we have \(n_2\le 33\) and \(d\le 156\);

  • in the case that \(q=3\), we have \(n_2\le 35\) and \(d\le 105\);

  • in the case that \(q=5\), we have \(n_2\le 39\) and \(d\le 81\);

  • in the case that \(q=7\), we have \(n_2\le 48\) and \(d\le 84\).

5 Final computations

The bounds for \(n_1\) and \(n_2\) are now small enough to perform a brute force computer search. However, before we perform this computer search we once again apply the reduction Step 3 with the bounds for \(n_1\) and \(n_2\) given by Lemma 12.

The reduction Step 3 is to reconsider inequality (22) which is

$$\begin{aligned} |s_2s_1^{-1}-1| <\frac{n_2!}{s_1}=n_2!\exp \left( {\mathop {\overbrace{-a_1\log 2-a_2\log 3-a_3\log 5-a_4\log 7}}\limits ^{:=-H}}\right) . \end{aligned}$$

An application of Lemma 3 yields

$$\begin{aligned} a_1\log 2+a_2\log 3+a_3\log 5+a_4\log 7=H\le \frac{1}{{\tilde{c}}_4}\left( \log ({\tilde{C}}{\tilde{c}}_3)-\log \left( \sqrt{{\tilde{c}}_1^2-S}-T\right) \right) , \end{aligned}$$

with \({\tilde{c}}_4=1\), \({\tilde{c}}_3=n_2!\). With the choice of \(C=10^{11}\) we have \({\tilde{c}}_1^2 \ge T^2+S\) and therefore obtain

$$\begin{aligned} a_1\log 2+a_2\log 3+a_3\log 5+a_4\log 7=H\le \log (10^{11} n_2!)-\log 69.52:=B. \end{aligned}$$

We will divide our brute force search into four segments:

  • \(n_2\le 33\);

  • \(n_2=34,35\);

  • \(36\le n_2\le 39\);

  • \(40 \le n_2 \le 48\).

For \(1\le n_2\le 33\) we proceed as follows:

  • We compute \(B=\log (10^{11} n_2!)-\log 69.52\).

  • For all \(1\le n_1 < \min \{n_2,23\}\) we compute \(B_7=\frac{B}{\log 7}\).

  • For all \(0\le x_4 \le B_7\) we compute \(B_5=\frac{B-x_4\log 7}{\log 5}\).

  • For all \(0\le x_3 \le B_5\) we compute \(B_3=\frac{B-x_4\log 7-x_3\log 5}{\log 3}\).

  • For all \(0\le x_2 \le B_3\) we compute \(B_2=\frac{B-x_4\log 7-x_3\log 5-x_2\log 3}{\log 2}\).

  • For all \(0\le x_1 \le B_2\) we compute \(M=n_2!-n_1!+2^{x_1}3^{x_2}5^{x_3}7^{x_4}\) and we compute

    • \(v_2=\nu _2(M)\);

    • \(v_3=\nu _3(M)\);

    • \(v_5=\nu _5(M)\);

    • \(v_7=\nu _7(M)\).

    If \(M=2^{v_2}3^{v_3}5^{v_5}7^{v_7}\) we have found a solution

    $$\begin{aligned} (n_1,n_2,x_1,x_2,x_3,x_4,v_2,v_3,v_5,v_7) \end{aligned}$$

    to the Diophantine equation (3) and append it to our list SolutionsMain of solutions to the Diophantine equation (3).

In the case that \(n_2=34\) or \(n_2=35\) the case that \(q=2\) is impossible. To use this fact efficiently we distinguish now between the two cases \(\nu _q(s_1)=d\) and \(\nu _q(s_2)=d\). In the case that \(\nu _q(s_1)=d\) holds we proceed as before. However in the case that \(\nu _q(s_2)=d\) we consider

$$\begin{aligned} |s_1s_2^{-1}-1| <\frac{n_2!}{s_2}=n_2!\exp \left( {\mathop {\overbrace{-b_1\log 2-b_2\log 3-b_3\log 5-b_4\log 7}}\limits ^{:=-H'}}\right) \end{aligned}$$

and we obtain by the same arguments that

$$\begin{aligned} b_1\log 2+b_2\log 3+b_3\log 5+b_4\log 7=H'\le \log (10^{11} n_2!)-\log 69.52=B. \end{aligned}$$

holds. Therefore, we proceed in the case that \(n_2=34\) or \(n_2=35\) as follows:

  • We compute \(B=\log (10^{11} n_2!)-\log 69.52\).

  • For all \(1\le n_1 \le 22\) we compute \(B_7=\frac{B}{\log 7}\).

  • For all \(0\le x_4 \le B_7\) we compute \(B_5=\frac{B-x_4\log 7}{\log 5}\).

  • For all \(0\le x_3 \le B_5\) we compute \(B_3=\frac{B-x_4\log 7-x_3\log 5}{\log 3}\).

  • For all \(0\le x_2 \le B_3\) we compute \(B_2=\frac{B-x_4\log 7-x_3\log 5-x_2\log 3}{\log 2}\).

  • For all \(0\le x_1 \le \min \{B_2,\max \{x_2,x_3,x_4\}\}\) we compute

    • \(M_1=n_2!-n_1!+2^{x_1}3^{x_2}5^{x_3}7^{x_4}\) (in case that \(d=\nu _q(s_1)\));

    • \(M_2=n_1!-n_2!+2^{x_1}3^{x_2}5^{x_3}7^{x_4}\) (in case that \(d=\nu _q(s_2)\));

    • \(v_2=\nu _2(M_1)\) and \(v'_2=\nu _2(M_2)\);

    • \(v_3=\nu _3(M_1)\) and \(v'_3=\nu _3(M_2)\);

    • \(v_5=\nu _5(M_1)\) and \(v'_5=\nu _5(M_2)\);

    • \(v_7=\nu _7(M_1)\) and \(v'_7=\nu _7(M_2)\).

    If \(M_1=2^{v_2}3^{v_3}5^{v_5}7^{v_7}\) we have found a solution with \(M_1=s_1\) and we have a solution

    $$\begin{aligned} (n_1,n_2,x_1,x_2,x_3,x_4,v_2,v_3,v_5,v_7) \end{aligned}$$

    to the Diophantine equation (3) and we append this solution to our list SolutionsMain of solutions to the Diophantine equation (3). Similarly, if \(M_2=2^{v'_2}3^{v'_3}5^{v'_5}7^{v'_7}\) we have found a solution with \(M_2=s_2\) and we have a solution

    $$\begin{aligned} (n_1,n_2,v'_2,v'_3,v'_5,v'_7,x_1,x_2,x_3,x_4) \end{aligned}$$

    to the Diophantine equation (3) which we append to our list of solutions.

In the case that \(36\le n_2\le 39\), the case that \(q=2\) and \(q=3\) are impossible; i.e. we proceed similarly as in the case that \(n_2=34\) or \(n_2=35\):

  • We compute \(B=\log (10^{11} n_2!)-\log 69.52\).

  • For all \(1\le n_1 \le 22\) we compute \(B_7=\frac{B}{\log 7}\).

  • For all \(0\le x_4 \le B_7\) we compute \(B_5=\frac{B-x_4\log 7}{\log 5}\).

  • For all \(0\le x_3 \le B_5\) we compute \(B_3=\frac{B-x_4\log 7-x_3\log 5}{\log 3}\).

  • For all \(0\le x_2 \le \min \{B_3,\max \{x_3,x_4\}\}\) we compute

    $$\begin{aligned} B_2=\frac{B-x_4\log 7-x_3\log 5-x_2\log 3}{\log 2}. \end{aligned}$$
  • For all \(0\le x_1 \le \min \{B_2,\max \{x_3,x_4\}\}\) we compute

    • \(M_1=n_2!-n_1!+2^{x_1}3^{x_2}5^{x_3}7^{x_4}\) (in case that \(d=\nu _q(s_1)\));

    • \(M_2=n_1!-n_2!+2^{x_1}3^{x_2}5^{x_3}7^{x_4}\) (in case that \(d=\nu _q(s_2)\));

    • \(v_2=\nu _2(M_1)\) and \(v'_2=\nu _2(M_2)\);

    • \(v_3=\nu _3(M_1)\) and \(v'_3=\nu _3(M_2)\);

    • \(v_5=\nu _5(M_1)\) and \(v'_5=\nu _5(M_2)\);

    • \(v_7=\nu _7(M_1)\) and \(v'_7=\nu _7(M_2)\).

    If \(M_1=2^{v_2}3^{v_3}5^{v_5}7^{v_7}\) we have found a solution with \(M_1=s_1\) and we have a solution

    $$\begin{aligned} (n_1,n_2,x_1,x_2,x_3,x_4,v_2,v_3,v_5,v_7) \end{aligned}$$

    to the Diophantine equation (3) and append it to our list SolutionsMain of solutions to the Diophantine equation (3). Similarly, if \(M_2=2^{v'_2}3^{v'_3}5^{v'_5}7^{v'_7}\) we have found a solution with \(M_2=s_2\) and we have a solution

    $$\begin{aligned} (n_1,n_2,v'_2,v'_3,v'_5,v'_7,x_1,x_2,x_3,x_4) \end{aligned}$$

    to the Diophantine equation (3) which we append to our list of solutions.

In the case that \(40\le n_2\le 48\), we have that \(q=7\) and we proceed as follows:

  • We compute \(B=\log (10^{11} n_2!)-\log 69.52\).

  • For all \(1\le n_1 \le 22\) we compute \(B_7=\frac{B}{\log 7}\).

  • For all \(0\le x_4 \le B_7\) we compute \(B_5=\frac{B-x_4\log 7}{\log 5}\).

  • For all \(0\le x_3 \le \min \{B_5,x_4\}\) we compute \(B_3=\frac{B-x_4\log 7-x_3\log 5}{\log 3}\).

  • For all \(0\le x_2 \le \min \{B_3,x_4\}\) we compute \(B_2=\frac{B-x_4\log 7-x_3\log 5-x_2\log 3}{\log 2}\).

  • For all \(0\le x_1 \le \min \{B_2,x_4\}\) we compute

    • \(M_1=n_2!-n_1!+2^{x_1}3^{x_2}5^{x_3}7^{x_4}\) (in case that \(d=\nu _q(s_1)\));

    • \(M_2=n_1!-n_2!+2^{x_1}3^{x_2}5^{x_3}7^{x_4}\) (in case that \(d=\nu _q(s_2)\));

    • \(v_2=\nu _2(M_1)\) and \(v'_2=\nu _2(M_2)\);

    • \(v_3=\nu _3(M_1)\) and \(v'_3=\nu _3(M_2)\);

    • \(v_5=\nu _5(M_1)\) and \(v'_5=\nu _5(M_2)\);

    • \(v_7=\nu _7(M_1)\) and \(v'_7=\nu _7(M_2)\).

    If \(M_1=2^{v_2}3^{v_3}5^{v_5}7^{v_7}\) we have found a solution with \(M_1=s_1\) and we have a solution

    $$\begin{aligned} (n_1,n_2,x_1,x_2,x_3,x_4,v_2,v_3,v_5,v_7) \end{aligned}$$

    to the Diophantine equation (3) and append it to our list SolutionsMain of solutions to the Diophantine equation (3). Similarly, if \(M_2=2^{v'_2}3^{v'_3}5^{v'_5}7^{v'_7}\) we have found a solution with \(M_2=s_2\) and we have a solution

    $$\begin{aligned} (n_1,n_2,v'_2,v'_3,v'_5,v'_7,x_1,x_2,x_3,x_4) \end{aligned}$$

    to the Diophantine equation (3) which we append to our list of solutions.

It takes about 150 min on a usual desktop PC to perform this computer search and obtain all 1430 solutions to Diophantine equation (3). For each solution

$$\begin{aligned} (n_1,n_2,a_1,a_2,a_3,a_4,b_1,b_2,b_3,b_4) \end{aligned}$$

in our list SolutionsMain we compute the quantity

$$\begin{aligned} c=2^{a_1}3^{a_2}5^{a_3}7^{a_4}-n_1! \end{aligned}$$

and sort our list SolutionsMain according to these values c. Therefore, we easily find all 1030 values of c such that the Diophantine equation (2) has at least two solutions. Note that the Diophantine equation (2) has exactly k solutions if the value c appears exactly \(\left( {\begin{array}{c}k\\ 2\end{array}}\right) \) times in our list SolutionsMain. Thus a search for values of c that appear exactly \(\left( {\begin{array}{c}k\\ 2\end{array}}\right) \) times leads to the lists of values of c such that Diophantine equation (2) has ten, six, five, four or three solutions, respectively.