Yesterday, I faced a problem that required me to count the sum of a geometric sequence modulo \(M\), \(M \in \mathbb{N} \). The sequence's \(ratio = 10\), and \(U_1 = 1\). Then we can get the sum mod \(M\) from \[((10^n -1)/9) \: mod \: M\]. But, for large \(n\), the formula isn't efficient. So I do searching. I got a better formula: \[(10^n \: mod \: \: (9 \times M) \: -1)/9\]
In the end, I got accepted by both formulas. But I can't prove why \[((10^n -1)/9) \: mod \: M \: = \: (10^n \: mod \: \: (9 \times M) \: -1)/9 \]
Please help me to prove it. Thank you.
*Sorry for my bad English, since English is not my first language.
In the end, I got accepted by both formulas. But I can't prove why \[((10^n -1)/9) \: mod \: M \: = \: (10^n \: mod \: \: (9 \times M) \: -1)/9 \]
Please help me to prove it. Thank you.
*Sorry for my bad English, since English is not my first language.