A360751 a(n) is the least perfect square average of two consecutive primes with 2*n gap between them, or -1 if no such number exists.
4, 9, 64, -1, 144, 625, 324, 2601, -1, 154449, 260100, 1681, 898704, 27225, 114244, -1, 278784, 223729, 4410000, 25281, 12888100, 4730625, 1512900, 4774225, -1, 8208225, 6130576, 1121481, 12744900, 34586161, 2433600, 45360225, 9784384, 1271279025, 64064016, -1, 69956496
Offset: 1
Keywords
Examples
a(3) = 64 is a term because 64 = 8^2, a perfect square, which is the least such number that is the average of two consecutive primes 61 and 67, with 2*3 = 6 being the prime gap between them.
Programs
-
Mathematica
seq[len_, pmax_] := Module[{s = Table[0, {len}], p = 3, c = 0, q, m, d}, Do[s[[i^2]] = -1; c++, {i, 2, Floor[Sqrt[len]]}]; While[c < len && p < pmax, q = NextPrime[p]; d = (q - p)/2; m = (p + q)/2; If[d <= len && s[[d]] == 0 && IntegerQ[Sqrt[m]], c++; s[[d]] = m]; p = q]; s]; seq[20, 10^7] (* Amiram Eldar, Feb 19 2023 *)
-
PARI
a(n) = if ((n>1) && issquare(n), return(-1)); forprime(p=2, oo, my(q=nextprime(p+1), s); if ((q-p == 2*n) && issquare(s=(p+q)/2), return(s))); \\ Michel Marcus, Feb 20 2023
Extensions
More terms from Amiram Eldar, Feb 19 2023
Comments