I am practising interview for Jane Street's trader internship and I found the following question.
Question: Calculate $2^{5104} \bmod 10$ using mental arithmetic.
I know that $2^5 \bmod 10 \equiv 2 \bmod 10.$
So,
\begin{align*}
2^{5104} & = (2^5)^{1020} 2^4 \\
& \equiv 2^{1020}2^4 \\
& = (2^5)^{204}2^4 \\
& \equiv(2^5)^{40}2^8 \\
& \equiv (2^5)^8 2^8 \\
& \equiv (2^5)^3 2 \\
& \equiv 6 \bmod 10.
\end{align*}
However, I find the calculations above very taxing if I use mental arithmetic. I believe there should be a faster way to answer the question but I am not able to find one.
No comments:
Post a Comment