# Sum of Liouville's function

Let $$\Omega(n)$$ be the number of prime factors of $$n$$ (with multiplicity)

compute: $$\sum_{n=1}^{2019} (-1)^{\Omega(n)} \left\lfloor \frac{2019}{n} \right\rfloor.$$

My thoughts:

there are obviously a couple cool properties with this function http://oeis.org/wiki/Liouville%27s_function_lambda(n)

if let $$\lambda(n) = (-1)^{\Omega(n)}$$

then we have

$$\lambda(mn) = \lambda(m) \cdot \lambda(n)$$

and if we sum over the divisors of $$n$$

$$\sum_{d|n} \lambda(d) = \begin{cases} 1 & \mbox{if } n \mbox{ is a square,}\; \\ 0 & \mbox{otherwise.}\;\end{cases}$$

But I am not sure how do I finish the last step of summing up to 2019...

$$\sum_{n \le x} \lambda(n)\lfloor \frac{x}{n}\rfloor = \sum_{n \le x} \lambda(n)\sum_{m \le x/n} 1 = \sum_{n \le x} \lambda(n)\sum_{nm \le x} 1 = \sum_{n \le x} \lambda(n)\sum_{n | d \le x} 1 = \sum_{d \le x} \sum_{n | d} \lambda(n) = \sum_{d \le x} 1_{d \text{ square}} = \lfloor \sqrt{x} \rfloor$$.
Let $$\displaystyle\;f(m) = \sum_{k=1}^m \lambda(n) \left\lfloor\frac{m}{k}\right\rfloor$$. Since $$\lfloor \frac{m}{k} \rfloor = 0$$ whenever $$k > m$$, we have
\begin{align}f(m) &= \sum_{n=1}^\infty \lambda(n)\left\lfloor\frac{m}{n}\right\rfloor\\ \implies f(m)-f(m-1) &= \sum_{n=1}^\infty \lambda(n)\left( \left\lfloor\frac{m}{n}\right\rfloor - \left\lfloor\frac{m-1}{n}\right\rfloor \right)\end{align} Notice $$\left\lfloor\frac{m}{n}\right\rfloor - \left\lfloor\frac{m-1}{n}\right\rfloor = \begin{cases}1, & n | m\\0, & n\not| m\end{cases}$$ We get $$f(m)-f(m-1) = \sum_{n|m}\lambda(n)\tag{*1}$$ Let's say the prime factorization of $$m$$ is $$\prod_{i=1}^k p_i^{e_i}$$. The factors of $$m$$ will have the form $$\prod_{i=1}^k p_i^{f_i}$$ where $$0 \le f_i \le e_i$$. This implies
$$\sum_{n|m}\lambda(n) = \sum_{f_k=0}^{e_k} \sum_{f_{k-1}=0}^{e_{k-1}} \cdots \sum_{f_1=0}^{e_i} (-1)^{f_1+\cdots+f_k} = \prod_{i=1}^k \sum_{f=0}^{e_i}(-1)^f\\ = \begin{cases} 1,& e_i \text{ is even for all }i\\ 0,&\text{ otherwise }\end{cases}$$ In other words, $$\sum\limits_{n|m} \lambda(m)$$ is $$1$$ when $$m$$ is a square and zero otherwise. This is what you already know. Substitute this back into $$(*1)$$, one can deduce
\begin{align}f(2019) &= f(1) + \sum_{m=2}^{2019}(f(m)- f(m-1))\\ &= 1 + \#\bigg\{ m \text{ is a square } : 2 \le m \le 2019 \bigg\}\\ &= \lfloor \sqrt{2019} \rfloor = 44\end{align}