Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Two days ago I asked about how to solve questions of the type:

Find last digit of $27^{27^{26}}$.


Find the remainder when $27^{45}$ is divided by $7$, using congruences.

I have now got this method completely, but I am still not able to solve these types of questions through Fermat's theorem. If somebody can solve one of the above problem step by step through Fermat's theorem or at least can give me some hint or provide anything that can be useful for me in solving these questions (if not direct solution) then it would be of tremendous help for me.

share|cite|improve this question
up vote 3 down vote accepted

I'll try my best to make it as clear as possible with an other question: Find the last digit of $7^{20}$ (next step ist, that you try to use this for your first problem):

Fermat' theorem says with $a,n$ coprime $$a^{\varphi(n)} \equiv 1 \mod n$$ With $\varphi(10)=4$ you know $7^4 \equiv 1 \mod 10$. Further more you get $7^{20} \equiv \left(7^4 \right)^5 \equiv 1 \mod 10$

So the last digit is a $1$.

Find the remainder of $27^{45} \div7$ is similar. You get $\varphi(7)=6$ and $27^6 \equiv 1 \mod 7$.

$27^{45} = 27^{6 \cdot 7 + 3} = 27^{6 \cdot 7} \cdot 27^3 = \left(27^6\right)^7 \cdot 27^3 \equiv 1^7 \cdot 27^3 \equiv 27^3 \mod 7$

I'm pretty sure you are able to solve the last equation.

share|cite|improve this answer
Your first example, with modulus 10, is actually Euler's Theorem, not Fermat's. The second example is easier without Fermat: $27\equiv-1\pmod7$, so .... – Gerry Myerson Aug 20 '12 at 13:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.