This task provides practice for core property of remainder taking operation in arithmetic - persisting of the
remainder over addition and multiplication. This important property is often used for checking results of
calculations, in competitive programming, in calculation checksums and especially for encryption.
See Modular arithmetic for thorough explanations.
We have a kind of long arithmetic calculation here, and we are asked about the result modulo some number (
result % M in many languages).
Input data will have:
sign valuewhere sign is either
*and value is an integer;
%instead and number by which the result should be divided to get the remainder.
Answer should give remainder of the result of all operations applied sequentially (starting with initial number) divided by the last number.
If you have troubles with this problem, please feel free to type its name in the "Search" box in the top menu and find relevant topics at our forum - probably you will get enough enlightenment from there.
input data: 5 + 3 * 7 + 10 * 2 * 3 + 1 % 11 answer: 1
In this case result after all operations applied sequentially is
All numbers will not exceed 10000 (though intermediate results could be very large).