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.

A007920 Smallest number k such that n + k is prime.

Original entry on oeis.org

2, 1, 0, 0, 1, 0, 1, 0, 3, 2, 1, 0, 1, 0, 3, 2, 1, 0, 1, 0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 1, 0, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 1, 0, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 3, 2, 1, 0, 1
Offset: 0

Views

Author

R. Muller

Keywords

Comments

a(n) = A007918(n) - n.

Examples

			a(22) = 1 because 22 + 1 = 23, the next higher prime.
a(23) = 0 because 23 is prime.
a(24) = 5 because 24 + 5 = 29, the next higher prime.
a(25) = 4 because 25 + 4 = 29, the next higher prime.
		

Crossrefs

Cf. A064722, A013632 (a slightly different version).

Programs

  • Mathematica
    distToPrime[n_] := If[PrimeQ[n], 0, NextPrime[n] - n]; Array[distToPrime, 110, 0] (* Harvey P. Dale, Sep 19 2011 *)
  • PARI
    a(n)=nextprime(n)-n

Extensions

More terms from Joanna S. Bartlett (s1117611(AT)cedarville.edu)