TITLE: Growth rate of signed sum of divisor function
QUESTION [5 upvotes]: Let $d(n)$ be the number of divisors function, i.e., $d(n)=\sum_{k|n} 1$ of the positive integer $n$. I know about some of the "gross" averages for this function, such as the estimate
$$
\sum_{n\leq x} d(n)=x \log x + (2 \gamma -1) x +{\cal O}(\sqrt{x})
$$
as well as its variability, e.g., the lim sup of the fraction
$$
\frac{\log d(n)}{\log n/\log \log n}
$$
is $\log 2$ while the lim inf of $d(n)$ is $2$, achieved whenever $n$ is prime.
How much is known about the statistics of $d(n)$? In particular, if we let $N$ grow to infinity, is there any way
to bound a sum of the form
$$
\left| \sum_{n=1}^N \varepsilon_n d(n) \right|
$$
from below for all or almost all $(\varepsilon_1,\cdots,\varepsilon_N)\in \{\pm 1\}^N$?

REPLY [3 votes]: An answer to Greg's comment. It's true about the parity. However the sum can take on any value between $-\sum_{n=1}^N d(n)$ to $\sum_{n=1}^N d(n)$ if it has the right parity. It's because if $k$ is any number between $0$ and $D(N)=\sum_{n=1}^N d(n),$ then there exists some subset $A_{k,N}$ of $\{1,\dots, N\}$ such that $\sum_{n\in A_{k,N}} d(n)=k.$
It follows from the relatively easy fact that $2D(N)+1 \geq D(N+1)$ or equivalently $D(N)+1 \geq d(n+1).$ Then the result follows by induction.
It's true for $N=1$ since $A_{0,1}$ the empty set and $A_{1,1}={1}.$
Suppose it's true for $N$, then if $0\le k \le D(N)$, let $A_{k,N+1}=A_{k,N}$
If $D(N+1)-D(N) \le k \le D(N+1),$ then let $A_{k,N+1}=A_{K,N} \cup N+1,$ where $K=D(N+1)-k.$ 
$2D(N)+1 \geq D(N+1),$ this covers all $k$ between $0$ and $D(N+1)$ finishing the induction.
Note that this idea shows the same can be done for any arithmetic function $f: \mathbb{N} \to \mathbb{N}$ with the same inequality $2F(N)+1 \geq F(N+1).$ Examples include the Euler totient function $\phi,$ the Carmichael lambda function $\lambda$ and many others.