Illustration of exponial(3) (not to scale), Picture by C.M. de Talleyrand-Périgord via Wikimedia Commons Everybody loves big numbers (if you do not, you might want to stop reading at this point). There are many ways of constructing really big numbers known to humankind, for instance:
In this problem we look at their lesser-known love-child the exponial , which is an operation de?ned for all positive integers n as
For example, exponial(1) = 1 and which is already pretty big. Note that exponentiation is right-associative: .
Since the exponials are really big, they can be a bit unwieldy to work with. Therefore we would like you to write a program which computes exponial(n) mod m (the remainder of exponial(n) when dividing by m).