login
A394630
Least index k such that prime(k)^2 + n! is again the square of a prime, or 0 if no such prime exists.
4
0, 0, 0, 0, 3, 4, 5, 7, 25, 175, 3848, 461, 4174, 68860, 3773, 218926, 354713, 2910933, 30498, 9788597, 21959114, 938903578, 294933055, 910526399, 20426640940, 114303248603, 434849901116, 79915701398721, 3449315100163, 212301237060282, 927957085532368
OFFSET
0,5
COMMENTS
Upon the observation that 5^2 + 4! = 25 + 24 = 49 = 7^2, it is natural to ask whether there are primes p, q such that q^2 - p^2 = n! for all n >= 4. This sequence gives the index (or "rank", or "primepi" values) of the corresponding primes p.
FORMULA
a(n) = A000720(A394631(n)) for all n. - M. F. Hasler, Apr 05 2026
EXAMPLE
For 0! = 1, there are no two primes p, q such that p^2 + 1 = q^2, therefore a(0) = 0.
Similarly, for n = 1, 2 and 3, with n! = 1, 2 and 6, there are no two primes p, q such that p^2 + n! = q^2, therefore a(n) = 0 for n = 1, 2 and 3.
For n = 4, we have the primes p = 5 and q = 7 such that 5^2 + 4! = 25 + 24 = 49 = 7^2, so a(4) = primepi(5) = 3.
For n = 5, we have 7^2 + 5! = 13^2, so a(5) = primepi(7) = 4.
For n = 6, we have 11^2 + 6! = 29^2, so a(6) = primepi(11) = 5.
PROG
(PARI) apply( {A394630(n, f=n!)=n>3&&forprime(p=3, oo, issquare(p^2+f, &q)&& isprime(q)&& return(primepi(p)))}, [0..15]) \\ For illustration; better use {A394630(n)=primepi(A394631(n))} with more efficient code given there.
(Sidef) sidef -N 'USE_PRIMECOUNT=1' -E 'for n in (0..30) { n!.diff_of_squares.first_by{.all_prime} || [0, 0] -> last.primepi.print(", ") }' # Daniel Suteu, Apr 09 2026
CROSSREFS
Cf. A001248 (squares of primes), A000142 (factorial), A000720 (primepi).
See A394631 for the primes p = prime(a(n)), A394632 for the primes q = sqrt(p^2 + n!).
See A394629 for the total number of solutions (p, q): n! = q^2 - p^2.
Sequence in context: A035359 A392634 A378963 * A325410 A269719 A214626
KEYWORD
nonn
AUTHOR
M. F. Hasler, Apr 04 2026
EXTENSIONS
More terms from Daniel Suteu, Apr 09 2026
STATUS
approved