Sum of p-adic absolute values In my current research I stumbled across a quite simple sum, in some way, namely the sum over the $p$-adic absolute values
$$
\sum_{i=1}^{n}|i|_{p} = \sum_{i=1}^{n} p^{-\nu_{p}(i)}
$$
in which $\nu_{p}(i)$ is the $p$-adic valuation of the integer $i$ and $n$ is an integer, too.
Does anyone know if this sum has some interesting properties, or appears in some interesting identities or theorems, or represents in any conceivable way some important fact related to $p$-adic numbers?
Thanks and Greetings
 A: Looking at it, this is similar to Legendre's formula for the p-adic valuation of $n!$, except that instead of multiplying, we're adding consecutive numbers. Additionally, we have to take into account a weight or how much each absolute value is, which complicates things a bit. Because of this, just like Legendre's formula requires you to compute the sum of digits of $n$ in base $p$, similarly here we'll need the digits of $n$ in base $p$ for my solution. Furthermore, I figured while I'm here I might as well work out the more general case for which your problem occurs as a special case when $s=1$,
$$\sum_{i=1}^n |i|_p^s$$
Let's look to the frequency at which a power of p occurs in the sum. We have that $\left\lfloor \frac{n}{p^k} \right\rfloor$ of the numbers are divisible by at least $p^k$. That means $\left\lfloor \frac{n}{p^k} \right\rfloor - \left\lfloor \frac{n}{p^{k+1}} \right\rfloor$ have exactly $p^{-k}$ as their p-adic absolute value.
$$\sum_{i=1}^n |i|_p = \sum_{k=0}^\infty p^{-sk}\left(\left\lfloor \frac{n}{p^k} \right\rfloor - \left\lfloor \frac{n}{p^{k+1}} \right\rfloor\right)$$
The sum is really finite because eventually the terms are all 0. Let's separate the sums and change the index around to make the floored terms match.
$$=\sum_{k=0}^\infty p^{-sk} \left\lfloor \frac{n}{p^k} \right\rfloor - \sum_{k=0}^\infty p^{-sk}\left\lfloor \frac{n}{p^{k+1}} \right\rfloor $$
$$=n+\sum_{k=1}^\infty p^{-sk} \left\lfloor \frac{n}{p^k} \right\rfloor - \sum_{k=1}^\infty p^{s(1-k)}\left\lfloor \frac{n}{p^k} \right\rfloor $$
$$=n+\sum_{k=1}^\infty (p^{-sk} - p^{s(1-k)})\left\lfloor \frac{n}{p^k} \right\rfloor $$
$$=n+(1 - p^s)\sum_{k=1}^\infty p^{-sk}\left\lfloor \frac{n}{p^k} \right\rfloor $$
Let's establish that the digit expansion of $n$ in base $p$ is $n = \sum_{k=0}^\ell n_kp^k$. Specifically, this means we can rewrite our sum's upper bound as $\ell$. From here on out, our steps are effectively mimicking the derivation of Legendre's formula.
$$=n+(1 - p^s)\sum_{k=1}^\ell p^{-sk}\left\lfloor \frac{n}{p^k} \right\rfloor $$
$$=n+(1 - p^s)\sum_{k=1}^\ell p^{-sk}\sum_{j=k}^\ell n_jp^{j-k} $$
$$=n+(1 - p^s)\sum_{j=1}^\ell \sum_{k=1}^j n_jp^{j-(s+1)k} $$
$$=n+(1 - p^s)\sum_{j=1}^\ell n_j p^j * p^{-s-1}\frac{p^{-(s+1)j}-1}{p^{-s-1}-1} $$
$$=n+\frac{p^{-s-1}(1 - p^s)}{p^{-s-1}-1}\sum_{j=1}^\ell n_j p^j (p^{-(s+1)j}-1) $$
$$=n+\frac{p^{-s-1}(1 - p^s)}{p^{-s-1}-1}\left(\sum_{j=0}^\ell n_j p^{-sj} - \sum_{j=0}^\ell n_j p^j \right)$$
$$=n+\frac{p^s-1}{p^{s+1}-1}\left(S_p(n,s) - n\right)$$
Here I've defined,
$$S_p(n,s) = \sum_{j=0}^\ell n_j p^{-sj}$$
Which satisfies $S_p(n,0) = \text{Sum of digits of n written in base p}$, which is a minor generalization of the sum of digits function found in Legendre's formula.
So here's our final formula for when $s=1$,
$$\sum_{i=1}^n |i|_p=n+\frac{S_p(n,1) - n}{p+1}$$
Another way to think of the $S_p(n,1)$ function is to take the base $p$ representation of n, and simply take the reciprocal of all the powers of primes in its digit representation. $S_p(n,1) = \sum_{j=0}^\ell n_j p^{-j}$

As a sanity check, the $p^n$ case is easy enough to solve, so by plugging in we have,
$$\sum_{i=1}^{p^n} |i|_p=p^n+\frac{p^{-n} - p^n}{p+1}$$
This is exactly equivalent to Vepir's comment earlier.
