login
A394632
Least prime q such that q^2 - n! is again the square of a prime, or 0 if no such prime exists.
5
0, 0, 0, 0, 7, 13, 29, 73, 223, 1201, 36313, 7109, 45341, 870517, 297377, 3240247, 6847843, 51948199, 80015629, 390403049, 1613360743, 22511523371, 34121600333, 162109085183, 949484701001, 5056628950459, 23744121396563, 2760884016693079, 562608177258653, 8107890641155673
OFFSET
0,5
COMMENTS
Upon the observation that 7^2 - 5^2 = 49 - 25 = 24 = 4!, it is natural to ask whether there are primes p, q such that q^2 - p^2 = n! for all n >= 4.
If d1 * d2 = n! = q^2 - p^2 = (q + p) * (q - p) then we can set d1 = (q - p) and d2 = (q + p). Solving for p and q in terms of d1 and d2 gives p = abs((d1 - d2) / 2) and q = (d1 + d2)/2. As p and q are prime we must have gcd(d1, d2) = 2. - David A. Corneth, Apr 04 2026
FORMULA
a(n) = sqrt(A394631(n)^2 + A000142(n)^2) = A000040(A394633(n)).
EXAMPLE
See A394631.
PROG
(PARI) apply( {A394632(n, f=n!)=n>3&&forprime(p=3, oo, issquare(p^2+f, &q)&& isprime(q)&& return(q))}, [0..16]) /* For illustration, slow for n > 20. Better use: */
{A394632(n)=sqrtint(A394631(n)^2+n!)} /* with more efficient code given there */
(PARI) \\ See Corneth link
(PARI) a(n)=if(n<4, return(0)); my(N=n!, L=List()); fordiv(vecprod(primes([3, n])), d, my(U=2*gcd(d^n, N)); my(p=(N/U+U)/2, q=abs(N/U-U)/2); if(ispseudoprime(q)&&ispseudoprime(p), listput(L, [p, q]))); vecsort(Vec(L))[1][1]; \\ Daniel Suteu, Apr 10 2026
CROSSREFS
Cf. A001248 (squares of primes), A000142 (factorial).
Cf. A394631 (primes p = sqrt(a(n)^2 - n!)), A394633 (primepi(a(n))), A394629 (total number of primes {p, q} s.t. q^2 - p^2 = n!).
Sequence in context: A182624 A096333 A133325 * A336117 A381095 A283709
KEYWORD
nonn
AUTHOR
M. F. Hasler, Apr 04 2026
EXTENSIONS
More terms from David A. Corneth, Apr 04 2026
STATUS
approved