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”).

a(1) = 0; for n >= 2, a(n) = n - (largest prime <= n).
20

%I #31 Aug 18 2024 16:43:10

%S 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,

%T 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,

%U 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

%N a(1) = 0; for n >= 2, a(n) = n - (largest prime <= n).

%H Harry J. Smith, <a href="/A064722/b064722.txt">Table of n, a(n) for n=1..1000</a>

%F a(n) = n - A007917(n).

%F a(n) = 0 iff n is 1 or a prime.

%F 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

%F a(n) = a(n-1)*0^A010051(n) + 1 - A010051(n), a(1) = 0. - _Reinhard Zumkeller_, Mar 23 2006

%F a(n) = n mod A007917(n). - _Michel Marcus_, Aug 22 2014

%F a(n) = A049711(n+1) - 1 for n >= 2. - _Pontus von Brömssen_, Jul 31 2022

%e a(26) = 26 - 23 = 3, a(37) = 37 - 37 = 0.

%p 0, seq(n - prevprime(n+1), n=2..100); # _Robert Israel_, Aug 25 2014

%t Join[{0},Table[n-NextPrime[n+1,-1],{n,2,110}]] (* _Harvey P. Dale_, Aug 23 2011 *)

%o (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

%Y Cf. A000040, A000720, A007917, A007920, A010051, A049711.

%K nonn,easy

%O 1,9

%A _Reinhard Zumkeller_, Oct 13 2001