# Does digit $6$ always lead to $\ 25921=161^2\$?

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$$

• Is there any sort of evidence except for the fact that you did not find any example ? – Captain Lama Apr 17 at 19:49
• 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. – Ross Millikan Apr 17 at 20:25
• @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. – Peter Apr 17 at 20:29

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$$.

• 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 – Shieru Asakoto May 5 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:

• $$x^2-2(1)y^2=1$$.
• $$\sqrt{2}=[1;2,2,\cdots]$$, the first 4 solutions are $$(3,2)$$, $$(17,12)$$, $$(99,70)$$ and $$(577,408)$$. These generate 3 7-smooth pairs: $$(1,2)$$, $$(8,9)$$, $$(49,50)$$.
• $$x^2-2(3)y^2=1$$.
• $$\sqrt{6}=[2;2,4,2,4,\cdots]$$, the first 4 solutions are $$(5,2)$$, $$(49,20)$$, $$(485,198)$$ and $$(4801,1960)$$. These generate 3 7-smooth pairs: $$(2,3)$$, $$(24,25)$$, $$(2400,2401)$$.
• $$x^2-2(5)y^2=1$$.
• $$\sqrt{10}=[3;6,6,\cdots]$$, the first 4 solutions are $$(19,6)$$, $$(721,228)$$, $$(27379,8658)$$ and $$(1039681,328776)$$. These generate 1 7-smooth pair: $$(9,10)$$.
• $$x^2-2(2\cdot 3)y^2=1$$.
• $$\sqrt{12}=[3;2,6,2,6,\cdots]$$, the first 4 solutions are $$(7,2)$$, $$(97,28)$$, $$(1351,390)$$ and $$(18817,5432)$$. These generate 2 7-smooth pairs: $$(3,4)$$, $$(48,49)$$.
• $$x^2-2(7)y^2=1$$.
• $$\sqrt{14}=[3;1,2,1,6,1,2,1,6,\cdots]$$, the first 4 solutions are $$(15,4)$$, $$(449,120)$$, $$(13455,3596)$$ and $$(403201,107760)$$. These generate 2 7-smooth pairs: $$(7,8)$$, $$(224,225)$$.
• $$x^2-2(2\cdot 5)y^2=1$$.
• $$\sqrt{20}=[4;2,8,2,8,\cdots]$$, the first 4 solutions are $$(9,2)$$, $$(161,36)$$, $$(2889,646)$$ and $$(51841,11592)$$. These generate 2 7-smooth pairs: $$(4,5)$$, $$(80,81)$$.
• $$x^2-2(2\cdot 7)y^2=1$$.
• $$\sqrt{28}=[5;3,2,3,10,3,2,3,10,\cdots]$$, the first 4 solutions are $$(127,24)$$, $$(32257,6096)$$, $$(8193151,1548360)$$ and $$(2081028097,393277344)$$. These generate 1 7-smooth pair: $$(63,64)$$.
• $$x^2-2(3\cdot 5)y^2=1$$.
• $$\sqrt{30}=[5;2,10,2,10,\cdots]$$, the first 4 solutions are $$(11,2)$$, $$(241,44)$$, $$(5291,966)$$ and $$(116161,21208)$$. These generate 1 7-smooth pair: $$(5,6)$$.
• $$x^2-2(3\cdot 7)y^2=1$$.
• $$\sqrt{42}=[6;2,12,2,12,\cdots]$$, the first 4 solutions are $$(13,2)$$, $$(337,52)$$, $$(8749,1350)$$ and $$(227137,35048)$$. These generate 2 7-smooth pairs: $$(6,7)$$, $$(4374,4375)$$.
• $$x^2-2(2\cdot 3\cdot 5)y^2=1$$.
• $$\sqrt{60}=[7;1,2,1,14,1,2,1,14,\cdots]$$, the first 4 solutions are $$(31,4)$$, $$(1921,248)$$, $$(119071,15372)$$ and $$(7380481,952816)$$. These generate 1 7-smooth pair: $$(15,16)$$.
• $$x^2-2(5\cdot 7)y^2=1$$.
• $$\sqrt{70}=[8;2,1,2,1,2,16,2,1,2,1,2,16,\cdots]$$, the first 4 solutions are $$(251,30)$$, $$(126001,15060)$$, $$(63252251,7560090)$$ and $$(31752504001,3795150120)$$. These generate 1 7-smooth pair: $$(125,126)$$.
• $$x^2-2(2\cdot 3\cdot 7)y^2=1$$.
• $$\sqrt{84}=[9;6,18,6,18\cdots]$$, the first 4 solutions are $$(55,6)$$, $$(6049,660)$$, $$(665335,72594)$$ and $$(73180801,7984680)$$. These generate 1 7-smooth pair: $$(27,28)$$.
• $$x^2-2(2\cdot 5\cdot 7)y^2=1$$.
• $$\sqrt{140}=[11;1,4,1,22,1,4,1,22,\cdots]$$, the first 4 solutions are $$(71,6)$$, $$(10081,852)$$, $$(1431431,120978)$$ and $$(203253121,17178024)$$. These generate 1 7-smooth pair: $$(35,36)$$.
• $$x^2-2(3\cdot 5\cdot 7)y^2=1$$.
• $$\sqrt{210}=[14;2,28,2,28,\cdots]$$, the first 4 solutions are $$(29,2)$$, $$(1681,116)$$, $$(97469,6726)$$ and $$(5651521,389992)$$. These generate 1 7-smooth pair: $$(14,15)$$.
• $$x^2-2(2\cdot 3\cdot 5\cdot 7)y^2=1$$.
• $$\sqrt{420}=[20;2,40,2,40,\cdots]$$, the first 4 solutions are $$(41,2)$$, $$(3361,164)$$, $$(275561,13446)$$ and $$(22592641,1102408)$$. These generate 1 7-smooth pair: $$(20,21)$$.

From the calculations above, it turns out that there are only 23 pairs of consecutive 7-smooth numbers. 18 of them are obviously too small to fulfill the second condition, so in order to save space I will take them out, remaining 5 candidate pairs:

• $$15, 16$$: $$180\nmid15\cdot16$$
• $$24, 25$$: $$180\nmid24\cdot25$$
• $$\color{red}{80, 81}$$: This is the case of $$6!\cdot 3!\cdot 3!+1$$.
• $$2400, 2401$$: $$907200\nmid2400\cdot2401$$*
• $$4374, 4375$$: $$907200\nmid4374\cdot4375$$*

*: One of the numbers is divisible by 7.

Most of the solutions are ruled out because of the second condition stated in the second paragraph. As there is only one solution fulfilling $$2^2\cdot 3^2\cdot 5\prod a_i!=\frac{(x-1)(x+1)}{4}$$ as in Keith's partial answer, 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.