cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A381766 #47 Apr 02 2025 13:21:04
%S A381766 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,
%T A381766 4,10,24,2,14,18,22,8,8,48,4,72,132,224,180,142,10,96,24,10,24,124,76,
%U A381766 2,164,34,196,120,34,24,128,118,8,6,34,2,2,8,116,18,552,6
%N 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.
%e A381766 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.
%p A381766 A381766 := proc(n)
%p A381766     local p ,a, ps;
%p A381766     p := ithprime(n) ;
%p A381766     ps := p ;
%p A381766     for a from 2 do
%p A381766         p := nextprime(p) ;
%p A381766         ps := ps+p ;
%p A381766         if isprime(ps-1) and isprime(ps+1) then
%p A381766             return a;
%p A381766         end if;
%p A381766     end do:
%p A381766 end proc:
%p A381766 seq(A381766(n),n=1..20) ; # _R. J. Mathar_, Apr 02 2025
%o A381766 (Python)
%o A381766 import sympy
%o A381766 def a(n):
%o A381766    p=sympy.prime(n);s=p;c=1
%o A381766    while not(sympy.isprime(s-1) and sympy.isprime(s+1)):p=sympy.nextprime(p);s+=p;c+=1
%o A381766    return c
%o A381766 (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
%Y A381766 Cf. A065091, A014574, A381868.
%K A381766 nonn
%O A381766 1,1
%A A381766 _Abhiram R Devesh_, Mar 08 2025