When $n=4,4\cdot n!-4n+1=4\times24-4\times4+1=9^2.$

I wonder if $4\cdot n!-4n+1$ can be a perfect square when $n>4$?

I searched $n$ from $5$ to $10000$ but no qualified number was found.

I know that:

(1) $n$ is even, since $-4n+1 \equiv1 \mod 8$;

(2) if $p|4n-1$ and $p\leq n/2$ then $p^2|4n-1$, here $p$ is prime;

(3) if $p \not|4n-1$ and $p\leq n$ then $\left (\frac{-4n+1}{p}\right) = 1$, here $p$ is prime, $\left (\frac{a}{p}\right)$ is Jacobi Symbol.

  • 1
    $\begingroup$ This is equivalent to $n((n-1)!-1)=m(m+1)$, maybe this helps (or maybe not). $\endgroup$ – YiFan Oct 12 at 11:52
  • 1
    $\begingroup$ I think it's still not known whether $n!+1$ can be a square for $n$ other than $4,5,7$. See oeis.org/A085692 – so there can be very hard problems not a million miles removed from yours. $\endgroup$ – Gerry Myerson Oct 12 at 12:12
  • $\begingroup$ $(n-1)!-1$ doesn't have smaller divisor than $n$. $\endgroup$ – Takahiro Waki Oct 12 at 12:26
  • $\begingroup$ @GerryMyerson As far as I know this has been solved in the meantime, but how is that related to this question ? $\endgroup$ – Peter Oct 12 at 12:46
  • 1
    $\begingroup$ checked up to $10^9$: for(n=1, 10^9, a= 1-4*n; t= 1; forprime(p=2, n, if(kronecker(a,p)==-1, t= 0; break()); ); if(t, b= 4*n!+a; if(issquare(b), print(n" "a" "b))); ) $\endgroup$ – Dmitry Ezhov Oct 13 at 1:21

If $\nu_p(4n-1)< \nu_p(n!)$ for all primes $p \mid (4n-1)$, then we have- $$x^2 = 4n!-4n+1=(4n-1)(\frac{4n!}{4n-1}-1)$$ and for every $p \mid (4n-1)$, we also have $p \mid \frac{4n!}{4n-1}$. Thus- $$\gcd\bigg(4n-1,\frac{4n!}{4n-1}-1\bigg)=1 \implies (4n-1)=x_1^2$$ However, this is impossible as $4n-1 \equiv 3 \pmod{4}$ and $3$ is not a quadratic residue modulo $4$.

Next, we try to find all values of $n$ for which $\nu_p(4n-1) \geqslant \nu_p(n!)$ for some odd prime $p \mid (4n-1)$. Let $\nu_p(4n-1)=t$ and $4n-1=kp^t$ for positive integers $k$ and $t$. We have- $$4n-1=kp^t \implies n=\frac{kp^t+1}{4}\geqslant p\bigg\lfloor\frac{kp^t+1}{4p}\bigg\rfloor$$

Thus, we use the first the first term in Legendre's formula to establish- $$\nu_p(n!) \geqslant\bigg\lfloor\frac{kp^{t}+1}{4p}\bigg\rfloor$$

We must then have- $$t\geqslant\bigg\lfloor\frac{kp^{t}+1}{4p}\bigg\rfloor$$

Using some grunt work checking, it is quite easy to see that the only cases for $t>1$ are: $$(t,k,p)=(2,1,3),(2,1,5),(2,1,7),(2,1,11),(2,2,3),(2,2,5),(2,3,3),(3,1,3)$$ and we have $4n-1=kp^t$, which shows that- $$4n-1 \in \{9,25,49,121,18,50,27,27\} \implies 4n-1\in \{9,18,25,27,49,50,121\}$$

As $4n-1 \equiv 3 \pmod{4}$, the only possibility is $4n-1=27$ showing $n=7$, which fails.

For $t=1$, we get $1 \geqslant \big\lfloor\frac{k+1}{4}\big\rfloor$. Thus, we must have $k<7$. As $4n-1$ is odd, so is $k$. Thus, we have the only possibilities being- $$4n-1 \in \{p,3p,5p,7p\} \implies n \in \bigg\{\frac{p+1}{4},\frac{3p+1}{4},\frac{5p+1}{4},\frac{7p+1}{4}\bigg\}$$

for some prime $p$.

Now, if $4n-1=qp$ where $q \in \{3,5,7\}$, since $t=1$, we have $q \neq p$. Then, we will have $$\nu_q(n!) \leqslant \nu_q(4n-1)$$ since otherwise, the expression will have an odd power of $q$ which is prime in all cases. It can easily be seen that this means $p<8$ which gives us the work of checking- $$4n-1 \in \{9,15,21,25,35,49\}$$ out of which the only values $3 \pmod{4}$ are $15$ and $31$, which give the cases $n=4,8$. Only $n=4$ works.

Finally, we are left with the case $4n-1=p$ i.e. $n=\frac{p+1}{4}$ where $p \equiv 3 \pmod{4}$ is a prime. We have- $$x^2=4\bigg(\frac{p+1}{4}\bigg)!-p$$

Consider a prime $q \leqslant \frac{p+1}{4}$ (Not as defined earlier). We have- $$\bigg(\frac{p}{q}\bigg)\bigg(\frac{q}{p}\bigg)=(-1)^{\frac{p-1}{2} \cdot \frac{q-1}{2}}$$

Since $x^2 \equiv -p \pmod{q}$ must be a quadratic residue, we have- $$\bigg(\frac{-p}{q}\bigg) = 1 \implies \bigg(\frac{p}{q}\bigg)=(-1)^{\frac{q-1}{2}} \implies \bigg(\frac{q}{p}\bigg)=(-1)^{\frac{p-3}{2}\cdot\frac{q-1}{2}}=1$$ as $p \equiv 3 \pmod{4}$.

This means that all odd primes till $\frac{p+1}{4}$ are quadratic residues modulo $p$. One can check the cases below to show $p > 7$ which shows that- $$4\bigg(\frac{p+1}{4}\bigg)!\equiv 0 \pmod{8} \implies x^2 \equiv -p \equiv 1 \pmod{8} \implies p \equiv 7 \pmod{8}$$

This shows that $2$ is also a quadratic residue modulo $p$. Since all primes till $\frac{p+1}{4}$ are quadratic residues, all numbers till $\frac{p+1}{4}$ are quadratic residues too.

This means that we already have $\frac{p-3}{4}$ cases where a quadratic residue is followed by another quadratic residue. However, for $p \equiv 3 \pmod{4}$, this must occur exactly $\frac{p-3}{4}$ times. This means that for the following cases, we will never have consecutive quadratic residues.

This can be proved incorrect with the first value succeeding $\frac{p+1}{4}$ that is $a \equiv 2 \pmod{6}$ as $a$ and $a+1$ have all prime factors less than $\frac{p+1}{4}$.

Thus, we have the only solution being $n=4$ in the positive integers.

  • $\begingroup$ First sentence, why is it that prime $p$ dividing $4n-1$ implies $p$ divides $4n!/(4n-1)$? $\endgroup$ – Gerry Myerson Oct 13 at 11:48
  • 1
    $\begingroup$ As $\nu_p(4n-1)<\nu_p(n!)$ $\endgroup$ – Haran Oct 13 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.