login
a(n) = Sum_{k = 1..n} (-1)^(Omega(k) - omega(k)), where Omega(k) counts prime factors of k with multiplicity and omega(k) counts distinct prime factors.
2

%I #21 Jan 01 2023 11:16:27

%S 1,2,3,2,3,4,5,6,5,6,7,6,7,8,9,8,9,8,9,8,9,10,11,12,11,12,13,12,13,14,

%T 15,16,17,18,19,20,21,22,23,24,25,26,27,26,25,26,27,26,25,24,25,24,25,

%U 26,27,28,29,30,31,30,31,32,31,30,31,32,33,32,33,34

%N a(n) = Sum_{k = 1..n} (-1)^(Omega(k) - omega(k)), where Omega(k) counts prime factors of k with multiplicity and omega(k) counts distinct prime factors.

%C Partial sums of A162511.

%H Amiram Eldar, <a href="/A327666/b327666.txt">Table of n, a(n) for n = 1..10000</a>

%F a(1) = 1, a(n) = a(n - 1) + (-1)^(Omega(n) - omega(n)) for n > 1.

%F a(n) ~ c * n, where c = A307868. - _Amiram Eldar_, Sep 18 2022

%e Omega(1) = omega(1) = 0. The difference is 0, so (-1)^0 = 1, so a(1) = 1.

%e Omega(2) = omega(2) = 1. The difference is 0, so (-1)^0 = 1, which is added to a(1) to give a(2) = 2.

%e Omega(3) = omega(3) = 1. The difference is 0, so (-1)^0 = 1, which is added to a(2) to give a(3) = 3.

%e Omega(4) = 2 but omega(4) = 1. The difference is 1, so (-1)^1 = -1, which is added to a(3) to give a(4) = 2.

%t Table[Sum[(-1)^(PrimeOmega[k] - PrimeNu[k]), {k, n}], {n, 70}]

%t f[p_, e_] := (-1)^(e - 1); Accumulate @ Table[Times @@ f @@@ FactorInteger[n], {n, 1, 100}] (* _Amiram Eldar_, Sep 18 2022 *)

%o (PARI) seq(n)={my(v=vector(n)); v[1]=1; for(k=2, n, v[k] = v[k-1] + (-1)^(bigomega(k)-omega(k))); v} \\ _Andrew Howroyd_, Sep 23 2019

%o (Python)

%o from functools import reduce

%o from sympy import factorint

%o def A327666(n): return sum(-1 if reduce(lambda a,b:~(a^b), factorint(i).values(),0)&1 else 1 for i in range(1,n+1)) # _Chai Wah Wu_, Jan 01 2023

%Y Cf. A001221, A001222, A002321, A002819, A008836, A046660, A069812, A076479, A162511, A174863, A307868.

%K nonn

%O 1,2

%A _Ilya Gutkovskiy_, Sep 21 2019