Back to problem set
Disclaimer: these are my personal solutions; they have not been
reviewed, so be careful relying on them as there might be errors. Some
competitions may have official solutions from the contest publishers which
you may wish to refer to instead if you’re looking for verified solutions.
Problem 2#
Find the remainder r, 1≤r≤13, when 21985 is divided by 13.
Hints#
Hint #1
You don’t actually need to compute this directly; can you reduce the problem?
Solution#
Open to see the solution; try solving it first or see the hints
above!
Let’s consider the ring of integers Z13, in which all arithmetic
is done mod13.
Computing 21985mod13 can be done over the full set of integers
Z (which is computationally intensive), or it can be done over
Z13, which may have a pattern, or a cycle, which may simplify
finding the answer.
Let’s compute the first few values of 2nmod13 in Z13:
20212223242526272829210211212213≡1mod13≡2mod13≡4mod13≡8mod13≡3mod13≡6mod13≡12mod13≡24mod13≡11mod13≡22mod13≡9mod13≡18mod13≡5mod13≡10mod13≡20mod13≡7mod13≡14mod13≡1mod13≡2mod13Thus, we see that there’s a cycle of size 12 so we need to compute 1985mod12=5 so 21985mod13=25mod13=6. ■
Verification#
The verification also includes the answer; try solving it furst or see
the hints above!
We can verify this answer directly via the Python REPL, because Python
supports arbitrarily-sized integer arithmetic:
$ python
>>> (2 ** 1985) % 13
6
or as a one-liner directly:
$ python -c "print((2 ** 1985) % 13)"
6