A007920 Smallest number k such that n + k is prime.
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
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.
Links
- T. D. Noe, Table of n, a(n) for n = 0..10000
- M. Popescu, V. Seleacu, About the Smarandache Complementary Prime Function, Smarandache Notions Journal, Vol. 7, No. 1-2-3, 1996, 12-22.
- F. Smarandache, Only Problems, Not Solutions!, via viXra.
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)
Comments