Borrowing the notation of @BobHanlon, the analytic solution to the sum is $x*Sum[10^{c*d},\{d,0,n\}]=x*(10^{c*(n+1)}-1)/(10^c-1)$.
Mod $m$, the equation may be written as follows
Mod[x,m] * (PowerMod[10, c*(n+1), m]-1) * PowerMod[PowerMod[10, c, m]-1, -1, m]
which takes advantage of the fast PowerMod
mentioned by @DanielLichtblau.
Note that substituting values for $x$, $c$, and $m$ gives an equation like
z * (PowerMod[10,c*(n+1),m] - 1) = 0,
where $z$ is a positive integer. Hence, the problem simplifies to finding a solution for PowerMod[10,c*(n+1),m]=1
.
MultiplicativeOrder[10,m]
gives the smallest integer $k$ such that $10^k=1$, mod $m$. The smallest positive integer multiple of $k$, say $i*k$, giving an integer solution for $n$ in $i*k=c*(n+1)$ solves the problem with $n=i*k/c-1$.
For example, $x=515$, $c=3$, and $m=53$ requires PowerMod[10,3*(n+1),53]=1
. In this case, MultiplicativeOrder[10,53]=13
, and $n=i*13/3-1$. The smallest integer $n=12$ results for $i=3$.
The large example gives PowerMod[10,6*(n+1),182593]=1
, and MultiplicativeOrder[10,182593]=182592
. Thus, $n=i*182592/6-1=30431$ when $i=1$.
The only calculation required is MultiplicativeOrder[10,m]
, which takes zero time. MultiplicativeOrder
is undefined when GCD[10,m]>1
, but the two moduli given in the question were both prime.
Mod[305745211 Sum[10^(6 d), {d, 0, n}], 182593] == 0
should beMod[305745211 Sum[10^(9 d), {d, 0, n}], 182593] == 0
because305745211
has 9 digits, not 6 $\endgroup$