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.

A097935 Number of primes that are not less than prime(n)-n and not greater than prime(n)+n.

Original entry on oeis.org

2, 3, 4, 4, 3, 5, 5, 5, 5, 5, 5, 6, 7, 7, 7, 8, 8, 9, 8, 9, 9, 10, 10, 12, 10, 10, 10, 11, 11, 12, 13, 13, 12, 13, 12, 12, 14, 16, 15, 15, 14, 15, 17, 17, 17, 17, 17, 18, 18, 19, 19, 19, 20, 18, 18, 20, 19, 19, 20, 21, 21, 21, 20, 21, 21, 23, 22, 23, 21, 22, 22, 22, 23, 24, 25
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 05 2004

Keywords

Examples

			a(10) = #{p prime: A000040(10)-10 <= p <= A000040(10)+10} = #{p prime: 19 <= p <= 39} = #{19,23,29,31,37} = 5.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := PrimePi[Prime[n] + n] - PrimePi[Prime[n] - n - 1];
    Array[a, 100] (* Jean-François Alcover, Jun 11 2019 *)
  • PARI
    a(n) = my(p=prime(n)); primepi(p+n) - primepi(p-n-1); \\ Michel Marcus, Jun 11 2019
  • Sage
    [len([k for k in (nth_prime(n)-n..nth_prime(n)+n) if is_prime(k)]) for n in (1..75)]  # Peter Luschny, Sep 03 2013
    

Formula

a(n) = A000720(A014688(n)) - A000720(A014689(n)-1).