A073445 Second differences of A002808, the sequence of composites.
0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, -1, 0, 1, 0, -1, 0, 1, -1, 0, 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, -1, 0, 1, 0, -1, 0, 0, 0, 1, -1, 0, 1, -1, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 1, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0
Offset: 1
Examples
From _Gus Wiseman_, Oct 10 2024: (Start) The composite numbers (A002808) are: 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, ... with first differences (A073783): 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, ... with first differences (A073445): 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, -1, ... (End)
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Crossrefs
Also first differences of A054546.
Positions of zeros are A376602.
Positions of nonzeros are A376603.
A002808 lists the composite numbers.
A064113 lists positions of adjacent equal prime gaps.
A333254 gives run-lengths of differences between consecutive primes.
Programs
-
Haskell
a073445 n = a073445_list !! (n-1) a073445_list = zipWith (-) (tail a073783_list) a073783_list -- Reinhard Zumkeller, Jan 10 2013
-
Mathematica
c[x_] := FixedPoint[x+PrimePi[ # ]+1&, x]; Table[c[w+2]-2*c[w+1]+c[w], {w, 200}] (* second program *) Differences[Select[Range[100],CompositeQ],2] (* Gus Wiseman, Oct 08 2024 *)
-
Python
from sympy import primepi def A073445(n): def iterfun(f,n=0): m, k = n, f(n) while m != k: m, k = k, f(k) return m return (a:=iterfun(f:=lambda x:n+primepi(x)+1,n))-((b:=iterfun(lambda x:f(x)+1,a))<<1)+iterfun(lambda x:f(x)+2,b) # Chai Wah Wu, Oct 03 2024
Formula
a(n) = c(n+2)-2*c(n+1)+c(n), where c(n) = A002808(n).