Consider a function $f: \mathbb{N}_0\to \mathbb{N}_0$ following the relations:
- $f(0)=0$
- $f(np)=f(n)$
- $f(n)=n+f\left ( \left \lfloor \dfrac{n}{p} \right \rfloor \right)$ when $n$ is not divisible by $p$
Let, $a_k$ be the maximum value of $f (n)$ for $0\leq n \leq p^k$. Find $a_k$.