Consider prime numbers with the property that the product of the factorials of the digits plus $1$ is a perfect square, for example the prime $$30241$$ leads to the square $$3!\cdot 0!\cdot 2!\cdot 4!\cdot 1!+1=17^2$$

If the prime number starts with digit $6$, the only square seems to be $\ 25921=161^2\ $ which appears if the prime contains of one digit $6$ , two digits $3$ and the rest digits $0$ or $1$.

Is another square possible, when the prime starts with digit $6$ ? To this, we would need factorials below $10!$ , at least one of them $6!$ , such that their product plus $1$ is a perfect square , other than $6!\cdot 3!\cdot 3!+1$

  • 3
    $\begingroup$ Is there any sort of evidence except for the fact that you did not find any example ? $\endgroup$ Apr 17, 2019 at 19:49
  • 2
    $\begingroup$ In your last paragraph you correctly note that the equation only depends on the digits of the number, not their order, so it makes sense to search on collections of digits. The ten digits can be ordered in $10!,$ about $3$ million ways, so just checking them in one order can save a lot of time. As you get lots of digits it is very likely that some permutation of them will be prime, so that seems the last thing to check. Demanding the number be prime seems strange as it is unrelated to whether the product of factorials is one less than a square, but it is your question. $\endgroup$ Apr 17, 2019 at 20:25
  • $\begingroup$ @RossMillikan I did that and according to my program, we need at least $30$ factorials to get another perfect square. I do not think that the primality is a great restriction because we can insert ones and zeros arbitarily. $\endgroup$
    – Peter
    Apr 17, 2019 at 20:29

2 Answers 2


A comment on strategy too long for the comment section, but not a complete answer:

You want to find $6!\prod a_i! +1=x^2$ where $a_i$ are single digits. Note that the single digits are $0,1,2,3,2^2,5,2\cdot 3,7,2^3,3^2$, so the factorials will all either be $1$ or will have only the prime factors $2,3,5,7$.

Rearranging, $6!\prod a_i!=x^2-1=(x-1)(x+1)$. LHS is even, so $(x-1)\ \text{and}\ (x+1)$ are both even. Successive even numbers have only a single factor of $2$ in common.

$2^2\cdot3^2\cdot5\cdot\prod a_i!=\frac{(x-1)}{2}\frac{(x+1)}{2}$. RHS are two consecutive numbers; hence their gcd is $1$. So the first problem is to find consecutive numbers which only have prime factors of $2,3,5,7$, and none in common.

$161$ leads to a solution because $\frac{161-1}{2}=80=2^4\cdot 5;\ \frac{161+1}{2}=81=3^4$.

$17$ leads to a solution (although not for the $6$ question) because $\frac{17-1}{2}=8=2^3;\ \frac{17+1}{2}=9=3^2$.

Finding candidate consecutive numbers will not necessarily lead to a solution, as the numbers of various prime factors will have to be distributable among the $a_i!$, which might prove difficult if (for example) the number of factors of $2$ is less than the number of factors of $3$ in the consecutive numbers. If consecutive numbers can be found that satisfy that requirement, then identifying suitable $a_i$ will be possible, and as OP points out, it should then be possible to generate a prime starting number by strategic insertion of digits $0,1$.

  • $\begingroup$ That's a fast method indeed, because all 7-smooth numbers up to $x$ can be checked in $\log^4(x)$ time. I have checked using this so far up to $x=10^{100}$ (within which there are exactly 51,428,828 7-smooth numbers) and no other solutions can be found $\endgroup$ May 5, 2019 at 2:12

The answer is: $25921=161^2$ is the only possible square.

This solution is based on Keith's partial solution on the requirements of the solution if one exists, and Strømer's Theorem, which is a theorem on the finitude of smooth pairs.

Keith pointed out that the necessary condition for a solution $x^2$ fulfilling the conditions of the question is that both $\frac{x-1}{2}$ and $\frac{x+1}{2}$ are 7-smooth. Another condition will be that, if both $\frac{x-1}{2}$ and $\frac{x+1}{2}$ are not divisible by 7, then $180\mid\frac{(x-1)(x+1)}{4}$, or otherwise $907200\mid\frac{(x-1)(x+1)}{4}$.

Strømer's Theorem states that there are only finitely many pairs of consecutive smooth numbers up to any specific degree of smooth. An algorithm invented by Strømer, later simplified by Lehmer, can be used to find all pairs of consecutive smooth numbers. As a result, we can inspect all 7-smooth pairs in reasonable time for such a solution.

The algorithm states that we need only $2^{\pi(k)}-1$ Pell equations to find all $k$-smooth pairs. Let $P$ be the set of prime numbers which are at most $k$, then the equations we need to solve are the following:

$$x^2-2(\prod_{q\in Q} q)y^2=1\text{ for every }Q\in (\mathcal{P}(P)\setminus\{2\})$$

We only need to inspect the first $\max(3, \frac{k+1}{2})$ solutions per equation, and each solution $(x,y)$ for the Pell equation gives a pair $(\frac{x-1}{2},\frac{x+1}{2})$ which may or may not be both $k$-smooth. For a Pell equation with the form $x^2-ay^2=1$, by analyzing the continued fraction of $\sqrt{a}$ the solutions are easy to find.

In this case, we need to find all 7-smooth pairs, so we need to solve $2^{\pi(k)}-1=15$ equations, and for each equation we need $\max(3, \frac{7+1}{2})=4$ pairs of solutions. The calculations are organized into the table below:

enter image description here
Table 1 All 15 Pell equations needed to generate all 23 7-smooth pairs (shown in green background). Click to enlarge.

From Table 1, there are only 23 pairs of consecutive 7-smooth numbers. They are organized into the table below:

enter image description here
Table 2 All 23 7-smooth pairs, where $a=\frac{x-1}{2}$ and $b=\frac{x+1}{2}$. Click to enlarge.

From Table 2, only 3 7-smooth pairs have a product divisible by 180, in which 2 are divisible by 7. Since neither of those is divisible by 907200, there is only one possible solution, which is indeed the $25921=161^2$ case, fulfilling $2^2\cdot 3^2\cdot 5\prod a_i!=\frac{(x-1)(x+1)}{4}$ as required in Keith's partial answer. As a result, your $6$ always leads to $25921=161^2$.

Footnote: I ran the exhaustion search up to $x=10^{425}$ using Keith's method before I found how to reach the conclusion of having no other solutions.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .