In this link : Project Euler problem #731 , I got a nice solution for my question but i'm missing a crucial part .
I want to get an explanation of this part of the answer : 
My question : Why did we calculate the numerator $mod$ $3^k$ ? I would like to get a demonstration , because i'm not familiar with modular arithmetic
The author of the answer states: "We only need the fractional part of $S_2$": Any number $n$ can be written as $n=m+r$ where $m$ is divisible by $3^k$ and $r=n\mod 3^k$. But $\frac{n}{3^k} = \frac{m}{3^k} + \frac{r}{3^k}$. Since $m$ is divisible by $3^k$ the first summand on the rhs is an integer and thus does not contribute to the fractional part of $\frac{n}{3^k}$. So it suffices to compute the $n\mod 3^k$. In this particular instance that seems to be more efficient computationally. EDIT: For a demonstration check Wikipedia or google