login
Number of composites between successive primes.
97

%I #66 Jan 02 2024 02:41:22

%S 0,1,1,3,1,3,1,3,5,1,5,3,1,3,5,5,1,5,3,1,5,3,5,7,3,1,3,1,3,13,3,5,1,9,

%T 1,5,5,3,5,5,1,9,1,3,1,11,11,3,1,3,5,1,9,5,5,5,1,5,3,1,9,13,3,1,3,13,

%U 5,9,1,3,5,7,5,5,3,5,7,3,7,9,1,9,1,5,3,5,7,3,1,3,11,7,3,7,3,5,11,1,17

%N Number of composites between successive primes.

%C a(n) is odd for n>1 since all primes except 2 are odd. - _Joel Brennan_, Jan 02 2023

%H T. D. Noe, <a href="/A046933/b046933.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = prime(n+1) - prime(n) - 1 = A000040(n+1) - A000040(n) - 1.

%F a(n) = A001223(n) - 1.

%F a(n) = 2*A028334(n) - 1 for n>1. - _Giovanni Teofilatto_, Apr 19 2010

%F a(n) = Sum_{i=1..n-1} A036263(i). - _Daniel Forgues_, Apr 07 2014

%e a(1) = 0 since 2 is adjacent to 3;

%e a(2) = 1 since 4 is between 3 and 5;

%e a(4) = 3 = 11 - 7 - 1, etc.

%p A046933:=n->ithprime(n+1)-ithprime(n)-1; seq(A046933(n), n=1..100); # _Wesley Ivan Hurt_, Apr 15 2014

%t Differences[Prime[Range[100]]] - 1 (* _Arkadiusz Wesolowski_, Nov 18 2011 *)

%t Table[Prime[n + 1] - Prime[n] - 1, {n, 100}] (* _Wesley Ivan Hurt_, Apr 15 2014 *)

%t Prepend[Drop[Length/@SequenceSplit[Range@Prime@100,{_?PrimeQ}],1],0] (* _Federico Provvedi_, Jul 19 2021 *)

%o (PARI) a(n)=prime(n+1)-prime(n)-1 \\ _Charles R Greathouse IV_, Nov 20 2012

%o (Haskell)

%o a046933 n = a046933_list !! (n-1)

%o a046933_list = map (subtract 1) a001223_list

%o -- _Reinhard Zumkeller_, Dec 12 2012

%o (Python)

%o from sympy import prime

%o def A046933(n): return prime(n+1)-prime(n)-1 # _Chai Wah Wu_, Jan 02 2024

%Y Cf. A000040, A028334, A036263.

%Y Cf. A008996 (record values > 0).

%K easy,nonn,nice

%O 1,4

%A _Marc LeBrun_, Dec 11 1999