Answer the question
In order to leave comments, you need to log in
How to quickly find the remainder of the sum of digits?
Hello!
The program is given a number (perhaps a very large one), you need to sum all the numbers up to this number and find the remainder of the division of the number, which is also fed to the program. If you give a large number as the first parameter, then the program runs for a very long time. This process needs to be optimized. How can I do that?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
If you give a large number as the first parameter, then the program runs for a very long time.
n * (n + 1) / 2
? Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question