login
Second differences of A002808, the sequence of composites.
30

%I #28 Oct 10 2024 18:07:58

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

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

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

%N Second differences of A002808, the sequence of composites.

%H Reinhard Zumkeller, <a href="/A073445/b073445.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = c(n+2)-2*c(n+1)+c(n), where c(n)=A002808(n).

%F a(n) = A073783(n+1) - A073783(n). - _Reinhard Zumkeller_, Jan 10 2013

%e From _Gus Wiseman_, Oct 10 2024: (Start)

%e The composite numbers (A002808) are:

%e 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, ...

%e with first differences (A073783):

%e 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, ...

%e with first differences (A073445):

%e 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, -1, ...

%e (End)

%t c[x_] := FixedPoint[x+PrimePi[ # ]+1&, x] Table[(c[w+2]-2*c[w+1])+c[w]), {w, 1, 1000}]

%t (* second program *)

%t Differences[Select[Range[100],CompositeQ],2] (* _Gus Wiseman_, Oct 08 2024 *)

%o (Haskell)

%o a073445 n = a073445_list !! (n-1)

%o a073445_list = zipWith (-) (tail a073783_list) a073783_list

%o -- _Reinhard Zumkeller_, Jan 10 2013

%o (Python)

%o from sympy import primepi

%o def A073445(n):

%o def iterfun(f,n=0):

%o m, k = n, f(n)

%o while m != k: m, k = k, f(k)

%o return m

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

%Y Also first differences of A054546.

%Y For first differences we had A073783 (ones A375929), run-lengths A376680.

%Y Positions of zeros are A376602.

%Y Positions of nonzeros are A376603.

%Y Positions of ones are A376651, negative-ones A376652.

%Y A002808 lists the composite numbers.

%Y A064113 lists positions of adjacent equal prime gaps.

%Y A333254 gives run-lengths of differences between consecutive primes.

%Y Other second differences: A036263 (prime), A376590 (squarefree), A376596 (prime-power), A376604 (Kolakoski).

%Y Cf. A076259, A174965, A251092, A376562, A376593, A376599.

%K sign,easy

%O 1,1

%A _Labos Elemer_, Aug 01 2002