Yesterday, I faced a problem that required me to count the sum of a geometric sequence modulo M, M∈N. The sequence's ratio=10, and U1=1. Then we can get the sum mod M from ((10n−1)/9)modM. But, for large n, the formula isn't efficient. So I do searching. I got a better formula: (10nmod(9×M)−1)/9
In the end, I got accepted by both formulas. But I can't prove why ((10n−1)/9)modM=(10nmod(9×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 ((10n−1)/9)modM=(10nmod(9×M)−1)/9
Please help me to prove it. Thank you.
*Sorry for my bad English, since English is not my first language.