login
A394633
Least index k such that prime(k)^2 - n! is again the square of a prime, or 0 if no such prime exists.
3
0, 0, 0, 0, 4, 6, 10, 21, 48, 197, 3854, 911, 4705, 69137, 25797, 232944, 466932, 3110924, 4670197, 20851430, 80081977, 987827086, 1470388038, 6545264485, 35778005903, 179227960118, 797794938348, 79971185783965, 17084369697743, 227738431773765, 1024021410267278
OFFSET
0,5
COMMENTS
Upon the observation that 5^2 + 4! = 7^2 and 7^2 + 5! = 13^2, it is natural to ask whether for all n >= 4, there are primes p, q such that p^2 + n! = q^2.
This sequence gives the indices (or "primepi" values) of the primes q.
At present, it appears to be much easier to compute the primes q = A394632(n) than a(n) = primepi(q) for primes as huge as prime(a(30) ~ 10^15) and beyond.
FORMULA
a(n) = A000720(A394632(n)).
EXAMPLE
For n < 4 there are no primes p, q such that p^2 + n! = q^2, since 3^2 - 2^2 = 5 and 5^2 - 3^2 = 16 is already too large.
For n = 4 we have 5^2 + 4! = 7^2 and 7 is the 4th prime, so a(4) = 4.
For n = 5 we have 7^2 + 5! = 13^2 and 11 is the 6th prime, so a(5) = 6.
For n = 6 we have 11^2 + 6! = 29^2 and 29 is the 10th prime, so a(6) = 10.
See A394631 for more.
PROG
(PARI) apply( {A394633(n, f=n!)=n>3&&forprime(p=3, oo, issquare(p^2+f, &q)&& isprime(q)&& return(primepi(q)))}, [0..16])
/* or better: */ A394633(n) = primepi(A394632(n))
CROSSREFS
Cf. A001248 (squares of primes), A000142 (factorial), A000720 (primepi).
See A394632 for prime(a(n)) and further information, A394629 for the number of solutions (p, q).
Sequence in context: A185913 A243119 A277343 * A077065 A131867 A252656
KEYWORD
nonn
AUTHOR
M. F. Hasler, Apr 04 2026
EXTENSIONS
More terms from Daniel Suteu, Apr 07 2026
STATUS
approved