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.

A359300 a(n) = (distance from n to nearest prime >= n) - (distance from n to nearest prime <= n).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 2, 0, -2, 0, 4, 2, 0, -2, -4, 0, 0, 0, 4, 2, 0, -2, -4, 0, 2, 0, -2, 0, 0, 0, 2, 0, -2, 0, 4, 2, 0, -2, -4, 0, 4, 2, 0, -2, -4, 0, 0, 0, 4, 2, 0, -2, -4, 0, 2, 0, -2, 0, 0, 0, 4, 2, 0, -2, -4, 0, 2, 0
Offset: 2

Views

Author

Clark Kimberling, Jan 01 2023

Keywords

Examples

			a(8) = 2 because (11-8) - (8-7) = 2.
		

Crossrefs

Programs

  • Maple
    f:= n -> nextprime(n-1) + prevprime(n+1) - 2*n:
    map(f, [$2..100]); # Robert Israel, Jan 03 2023
  • Mathematica
    u[n_] := If[PrimeQ[n], n, NextPrime[n]];
    v[n_] := If[PrimeQ[n], n, NextPrime[n, -1]];
    Table[u[n] - n - (n - v[n]), {n, 2, 350}]

Formula

a(n) = A007917(n) + A007918(n) - 2*n. - Bernard Schott, Jan 01 2023