login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A064722
a(1) = 0; for n >= 2, a(n) = n - (largest prime <= n).
20
0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 0, 1, 2, 3
OFFSET
1,9
LINKS
FORMULA
a(n) = n - A007917(n).
a(n) = 0 iff n is 1 or a prime.
Computable also as a "commutator": pi(prime(m)) - prime(pi(m)) = A000720(A000040(m))-A000040(A000720(m)). Labels position of composites between 2 consecutive primes. - Labos Elemer, Oct 19 2001
a(n) = a(n-1)*0^A010051(n) + 1 - A010051(n), a(1) = 0. - Reinhard Zumkeller, Mar 23 2006
a(n) = n mod A007917(n). - Michel Marcus, Aug 22 2014
a(n) = A049711(n+1) - 1 for n >= 2. - Pontus von Brömssen, Jul 31 2022
EXAMPLE
a(26) = 26 - 23 = 3, a(37) = 37 - 37 = 0.
MAPLE
0, seq(n - prevprime(n+1), n=2..100); # Robert Israel, Aug 25 2014
MATHEMATICA
Join[{0}, Table[n-NextPrime[n+1, -1], {n, 2, 110}]] (* Harvey P. Dale, Aug 23 2011 *)
PROG
(PARI) { for (n = 1, 1000, if (n>1, a=n - precprime(n), a=0); write("b064722.txt", n, " ", a) ) } \\ Harry J. Smith, Sep 23 2009
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Reinhard Zumkeller, Oct 13 2001
STATUS
approved