Using PARI/GP, I searched for primes of the form $n!\pm k$ where $k \ne 2$ is prime and $n\in \Bbb{N}$.

With the help of user Peter, we covered a range of $k \le 10^7$ and couldn't find a prime $k$ for which there is no prime of either form $n!+k$ or $n!-k$.


$(1)$ When $n \ge k$, $n! \pm k$ cannot be prime as $k$ will be a factor of $n! \pm k$. This means that there are a finite number of primes of the form $n! \pm k$ for each $k$.

$(2)$ As $k$ increases, the number of primes of the form $n!\pm k$ also seems to increase. The reason for this is that as $k$ increases, the number of $n$ for which $n!\pm k$ may be prime also increases as all $n \lt k$ may give prime $n!\pm k$.

For those who want to carry forward the search here is the PARI/GP code:

for(k=1, 10^4,b=0; for(n=1, prime(k), if(ispseudoprime(n!+prime(k))==1, b=b+1)); print([prime(k), b]))

The first column of output will give the $k$ and the second column will the number of times $n!+k$ is prime for that given $k$. Here are the first few lines of output:

[2, 1]
[3, 1]
[5, 3]
[7, 4]
[11, 5]
[13, 3]
[17, 6]
[19, 7]

For rest of the output computed till now click here.


Is there any prime $k\ne 2$ for which there are no primes of the form $n!\pm k$?


I decided to test some other factorial-like functions and they gave surprisingly similar results.

For any prime $k$, there is at least one prime of the form:

$(1)$ $p_n$#$\pm k$, where $p_n$# is the primorial function and $k\gt 5$. This was verified for the range of $k\le 10^7$.

$(2)$ $n!!\pm k$, where $n!!$ is the double factorial and $k\gt 2$. This was verified for the range $k\le 10^5$.

$(3)$ $2n!!\pm k$ where $n$ can only odd and $k\gt 5$. This was verified for the range $k\le 10^5$.

I find it strange that a function that grows relatively slow like $2^n+2131$ doesn't have a single prime even for $n\le 10^4$, but a fast-growing, factorial-like function like $n!+prime(k)$ has primes for every single $k$ even after being restricted by $n \lt k$.

  • 10
    $\begingroup$ Not likely to be known. I would regard a proof or disproof as out of reach of currently known mathematical methods. It's quite easy to come up with such intractable statements. $\endgroup$
    – quasi
    Jul 14, 2019 at 17:45
  • 4
    $\begingroup$ See e.g. OEIS sequence A175193. $\endgroup$ Jul 14, 2019 at 17:53
  • 1
    $\begingroup$ @quasi what separates this from those kind of statements is that this one has a good heuristic reason of why it may be true and is backed up with a lot of computational evidence. $\endgroup$
    – Mathphile
    Jul 14, 2019 at 17:57
  • 4
    $\begingroup$ Or you want to say every prime has another prime at distance n!. This is unlikely to be deciphered as it would require finding the relationship between prime numbers and factorial within additive group. However it is not bad to try figuring out the statistics of the same, maybe some form of what distance between two primes may contain can help. At the moment I see nothing in any theory that can help about this to any extent (apart from statistical analysis of course). $\endgroup$
    – user681293
    Jul 14, 2019 at 18:00
  • 3
    $\begingroup$ @quasi: Typically this kind of statements are coming from an initial analysis that confirms that we have not one or two but the abundant number of cases as n increases. In this particular case the situation is maybe linear as it looks being linear at first. The trick is, we see the number increasing abundantly yet we cannot prove that we have one regular case :( Poor us and our understanding of primes :( $\endgroup$
    – user681293
    Jul 14, 2019 at 18:16

2 Answers 2


Under the random model for the primes I find the probability there is a prime $n!+k$ is about $a_k= \prod_{n=1}^k (1-\frac{\ln (n!+k)}{n!+k})$ and the probability that for some $K\ge K_0$ there is no prime $n!+K$ is $$f(K_0)=\sum_{K\ge K_0} (1-a_K)\prod_{k=K_0}^{K-1} a_k $$ Then we need to estimate $a_k$ and $f(K_0)$, the random model says your conjecture has a chance to hold only if $\lim_{K_0 \to \infty} f(K_0)=0$, otherwise $\forall K_0, f(K_0) = 1$ and under the random model for some $k$ there is no prime $n!+k$ almost surely.

  • 2
    $\begingroup$ There's almost always at least 1 n eliminated in the first p values mod p. $\endgroup$
    – user645636
    Jul 15, 2019 at 1:00
  • $\begingroup$ if you can recommend any papers on the Random model for primes I would greatly appreciate this thank you $\endgroup$ Dec 15, 2020 at 9:38

I am not sure, but, it seems that if the Diophantine equation in $4$ variables $$p^2-3p+2=\sum_{j=2}^{p-1}(4b_jc_j+2b_j+2c_j-j!)$$ does not have solutions with the conditions $p\geq 7$ and $b_j,c_j \in \mathbb N$ and $4b_jc_j+2b_j+2c_j-j!>0$ for $j=2,...,p-1$ then you should have a prime in the set $\{2!+p,...,(p-1)!+p\}$

This comment-answer can be used to justify some comments that your conjecture could be hard.


You must log in to answer this question.

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