OFFSET
1,5
COMMENTS
If the prime gaps above and below a prime p have the same length, p is called a balanced prime (see A006562). Likewise, if the prime gaps above and below the n-th prime gap have the same length, this gap might be called a balanced prime gap. These gaps correspond to nonzero terms a(n). Similarly, if a(n) >= 2, the n-th prime gap is the equivalent of a doubly balanced prime (A051795), and so on. - Peter Munn, Jan 08 2023
FORMULA
a(n) = min( {n-1} U {k : 0 <= k <= n-2 and prime(n-k-1) + prime(n+k+2) <> prime(n) + prime(n+1)} ). - Peter Munn, Jan 08 2023
EXAMPLE
For n = 1, prime(1) + prime(2) = 2 + 3 = 5; "prime(0)" does not exist, so a(1) = 0.
For n = 4:
j = 0: prime(4) + prime(5) = 7 + 11 = 18;
j = 1: prime(3) + prime(6) = 5 + 13 = 18;
j = 2: prime(2) + prime(7) = 3 + 17 = 20 != 18, so a(4) = 1.
For n = 5:
j = 0: prime(5) + prime(6) = 11 + 13 = 24;
j = 1: prime(4) + prime(7) = 7 + 17 = 24;
j = 2: prime(3) + prime(8) = 5 + 19 = 24;
j = 3: prime(2) + prime(9) = 3 + 23 = 26 != 24, so a(5) = 2.
PROG
(Python)
import sympy
offset = 1
N = 100
l = []
for n in range(offset, N+1):
j = 0
first_sum = sympy.prime(n-j)+sympy.prime(n+j+1)
while (n-j) > 1:
j += 1
sum = sympy.prime(n-j)+sympy.prime(n+j+1)
if sum != first_sum:
break
l.append(max(0, j-1))
print(l)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alexandre Herrera, Jan 01 2023
EXTENSIONS
Introductory phrase added to name by Peter Munn, Jan 08 2023
STATUS
approved