Why is this sum equal to the Logarithmic Integral? I am using this sum:
$$\sum_{k=1}^\infty \frac{(-1)^{k-1}}{k}\left((-1)^{k-1} (n-1) + \sum_{j=1}^{k-1}\frac{(-1)^{j+k-1}n (\log n)^j}{j!}\right)$$
Empirically, this is precisely equal to
$$\sum_{k=1}^\infty \frac{(\log n)^k}{k! k}$$
which is the most significant term in this expansion of the logarithmic integral
$$\operatorname{li}(n) = \log \log n + \gamma + \sum_{k=1}^\infty \frac{(\log n)^k}{k! k}$$
where $\gamma$ is the Euler-Mascheroni constant.
Can anyone show why my sum is equal to the sum from the logarithmic integral?
 A: I'll start the same way as Sasha, except that I'll first replace $n$ with $\exp\,z$:
$$\frac1{k}\left(-1+\exp\,z\sum_{j=0}^{k-1}\frac{(-z)^j}{j!}\right)$$
From here, we recall that the partial sums of the exponential function possess the following integral representation (see here for a proof):
$$\exp(-u)\sum_{j=0}^{k-1}\frac{u^j}{j!}=\frac1{(k-1)!}\int_u^\infty t^{k-1} \exp(-t)\mathrm dt$$
so we make the replacement:
$$-\frac1{k}+\frac1{k!}\int_{-z}^\infty t^{k-1} \exp(-t)\mathrm dt$$
Let's complicate things a bit:
$$-\frac{(k-1)!}{k!}+\frac1{k!}\int_{-z}^\infty t^{k-1} \exp(-t)\mathrm dt$$
and replace $(k-1)!=\Gamma(k)$ with its integral representation:
$$\frac1{k!}\left(-\int_0^\infty t^{k-1} \exp(-t)\mathrm dt+\int_{-z}^\infty t^{k-1} \exp(-t)\mathrm dt\right)$$
which simplifies:
$$\frac1{k!}\int_{-z}^0 t^{k-1} \exp(-t)\mathrm dt$$
We now treat the sum
$$\sum_{k=1}^\infty \frac1{k!}\int_{-z}^0 t^{k-1} \exp(-t)\mathrm dt$$
and swap summation and integration (justification left to the reader):
$$\int_{-z}^0\left(\sum_{k=1}^\infty \frac{t^{k-1}}{k!}\right)\exp(-t)\mathrm dt$$
which becomes
$$\int_{-z}^0\left(\frac{\exp\,t-1}{t}\right)\exp(-t)\mathrm dt=\int_{-z}^0\frac{1-\exp(-t)}{t}\mathrm dt=-\int_z^0\frac{1-\exp\,t}{-t}\mathrm dt=\int_0^z\frac{\exp\,t-1}{t}\mathrm dt$$
and since
$$\int_0^z\frac{\exp\,t-1}{t}\mathrm dt=\sum_{j=1}^\infty \frac{z^j}{j! j}$$
the claim is proven.
A: First of all note that the term being added to the inner sum can be absorbed into the sum as follows:
$$
  (-1)^{k-1} (n-1) + \sum_{j=1}^{k-1} (-1)^{j+k-1} n \frac{\log^j n}{j!} = 
  (-1)^k \left( 1 -  \sum_{j=0}^{k-1} (-1)^{j} n \frac{\log^j n}{j!} \right)
$$
Now, write $1 = \sum_{j=0}^{\infty} (-1)^{j} n \frac{\log^j n}{j!}$. Thus the original sum becomes
$$
 \mathcal{S} = \sum_{k=1}^\infty \frac{1}{k} \sum_{j=k}^{\infty} (-1)^{j} n \frac{\log^j n}{j!}
$$
Now exchange the order of summation $\sum_{k=1}^\infty \sum_{j=k}^\infty \to \sum_{j=1}^\infty \sum_{k=1}^{j}$:
$$
  \mathcal{S} = \sum_{j=1}^\infty  \sum_{k=1}^{j} \frac{1}{k} (-1)^{j} n \frac{\log^j n}{j!} =  n \sum_{j=1}^\infty (-1)^{j} H_j  \frac{\log^j n}{j!}
$$
I am not sure at the spot how to manually convert this into logarithmic integral function, but Mathematica can solve this sum in terms of LogIntegral[n]:
In[179]:= 
n Sum[(-1)^j HarmonicNumber[j] Log[n]^j/j!, {j, 1, Infinity}] == 
    Log[Log[n]] + EulerGamma - LogIntegral[n] // FullSimplify[#, n > 1] &

Out[179]= True

