Modular Calculator

Problem #14

Tags: arithmetic modulo loops

Who solved this?

Also available in: Spanish

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).

If you are curious why modular arithmetic is that important, you can see Public Key Cryptography Intro and RSA Cryptography exercises.

Input data will have:

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:
+ 3
* 7
+ 10
* 2
* 3
+ 1
% 11


In this case result after all operations applied sequentially is 397.

All numbers will not exceed 10000 (though intermediate results could be very large).

You need to login to get test data and submit solution.