A381766 Starting from the n-th prime, a(n) is the minimum number > 1 of consecutive primes whose sum is the average of a twin prime pair.
57, 180, 2, 2, 4, 2, 8, 2, 100, 2, 16, 18, 26, 12, 160, 4, 70, 70, 2, 12, 6, 4, 76, 202, 2, 4, 4, 10, 24, 2, 14, 18, 22, 8, 8, 48, 4, 72, 132, 224, 180, 142, 10, 96, 24, 10, 24, 124, 76, 2, 164, 34, 196, 120, 34, 24, 128, 118, 8, 6, 34, 2, 2, 8, 116, 18, 552, 6
Offset: 1
Keywords
Examples
a(3) = 2 because we need to add 5 and 7, to reach the average of the twin primes 11 and 13, which is 12.
Programs
-
Maple
A381766 := proc(n) local p ,a, ps; p := ithprime(n) ; ps := p ; for a from 2 do p := nextprime(p) ; ps := ps+p ; if isprime(ps-1) and isprime(ps+1) then return a; end if; end do: end proc: seq(A381766(n),n=1..20) ; # R. J. Mathar, Apr 02 2025
-
PARI
a(n) = my(p=prime(n), s=p, nb=1); while (!isprime(s-1) || !isprime(s+1), p=nextprime(p+1); s+=p; nb++); nb; \\ Michel Marcus, Apr 02 2025
-
Python
import sympy def a(n): p=sympy.prime(n);s=p;c=1 while not(sympy.isprime(s-1) and sympy.isprime(s+1)):p=sympy.nextprime(p);s+=p;c+=1 return c