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.

A370796 Number of primes between (prime(n)+1)^2 and (prime(n+1)-1)^2.

Original entry on oeis.org

2, 0, 0, 7, 0, 10, 0, 14, 32, 0, 38, 23, 0, 24, 51, 53, 0, 62, 30, 0, 71, 33, 76, 124, 44, 0, 42, 0, 51, 301, 48, 114, 0, 233, 0, 122, 126, 59, 135, 133, 0, 283, 0, 66, 0, 386, 396, 77, 0, 86, 173, 0, 349, 177, 187, 198, 0, 199, 100, 0, 412, 636, 113, 0, 114, 668, 224, 463, 0, 119, 236, 359
Offset: 1

Views

Author

Rafik Khalfi, Mar 02 2024

Keywords

Comments

If (prime(n),prime(n+1)) is a twin prime pair, then a(n)=0.

Examples

			For n=1, (prime(1+1)-1)^2 = 4, (prime(1)+1)^2 = 9 and we have two primes between 4 and 9, so a(1)=2.
		

Crossrefs

Cf. A050216.

Programs

  • Maple
    A370796:= proc (n)
    local count, a, b, p:
    count := 0:
    a := (ithprime(n)+1)^2:
    b := (ithprime(n+1)-1)^2:
    p := n:
    while ithprime(p) <= b do if a <= ithprime(p) then count := count+1 end if:
    p := p+1 end do:
    return count end proc:
    A370796(1) := 2:
    map(A370796, [$1 .. 100]);
  • Mathematica
    Table[Abs[ PrimePi[(Prime[n+1]-1)^2]- PrimePi[(Prime[n]+1)^2]],{n,72}] (* James C. McMahon, Mar 02 2024 *)
  • Python
    from sympy import primepi, prime, nextprime
    def A370796(n): return -primepi(((p:=prime(n))+1)**2)+primepi((nextprime(p)-1)**2) if n>1 else 2 # Chai Wah Wu, Mar 27 2024

Formula

a(n) = A038107(A000040(n+1)-1) - A038107(A000040(n)+1) for all n > 1;
a(n) = A038107(A000040(n)+1) - A038107(A000040(n+1)-1) for n=1.