[Math] How to use Fermat’s little theorem to find $50^{50}\pmod{13}$

elementary-number-theoryexponentiationmodular arithmetic

I don't understand how to use Fermat's little theorem to find remainders e.g if we are asked to find remainder of $50^{50}$ on division by $13$, what is a and what is $p$ in the formula?

Also I wanted to check can we use both congruence classes as well as Fermat's little theorem to find such remainders? How would be write $50^{50}$ on division by $13$ in terms of congruence classes to find the remainder?

I don't exactly understand what a congruence class is, what does it tell us and how is it related to this?

Best Answer

$\require{begingroup}\begingroup\newcommand\Z{\mathbb Z}$Fermat's little theorem tells us something modulo a prime $p$: $a^{p-1}\equiv1\pmod p$: the 'modulus' of the congruence is $p$, not $a$. Now if you're asked to find some residue modulo $13$, then you would use congruences to reduce the given value modulo $13$, i.e., the congruences will have modulus $13$.
If for example you want to find the remainder of $50^{50}$ when divided by (='modulo') $13$, probably the calculations would look like $$50^{50}\equiv\ldots\equiv\ldots\equiv\ldots\equiv\ldots\pmod{13}$$ and the rightmost dots should contain a number between $0$ and $12$ (inclusive).

I'm not sure why you want to use congruence classes for finding $50^{50}\bmod13$, but, as you're asking: a congruence class modulo $m$ is defined as a (non-empty) subset of $\Z$ in which all elements are (pairwise) congruent modulo $m$. Moreover, the congruence class should contain all integers congruent to its elements.
For example, the congruence classes modulo $2$ are precisely the set of even integers and the set of odd integers. The congruence classes modulo $3$ are the integers of the form $3k$, those of the form $3k+1$, and those of the form $3k+2$. In general, there are $|m|$ congruence classes modulo $m$, and a shorthand to write them is $m\Z,\,m\Z+1,\,m\Z+2,\,\ldots,\,m\Z+|m|-1$.

Now if you're asked to find $50^{50}\bmod13$, since $50^{50}$ is a big number probably you want to reduce the exponent and base, without affecting the value modulo $13$. Fermat's Little Theorem (FLT) is a handy tool to reduce exponents: as $13\nmid50$, FLT gives $50^{12}\equiv1\pmod{13}$. We can use this as follows: $$50^{50}=50^{4\cdot12}\cdot50^2=(50^{12})^4\cdot50^2\overset{\rm\small FLT}\equiv1^4\cdot50^2=50^2\pmod{13}$$ and look, we've reduced the exponent from $50$ to $2$ by subtracting a multiple of $12=13-1$.
Because $50^2$ is still not so small, let us try to reduce the base modulo $13$. We could replace $50$ by its remainder modulo $13$, which is $11$. This would leave use with calculating $11^2\bmod13$. A little easier is to subtract $13$ one more time: $$50^2\equiv(50-4\cdot13)^2=(-2)^2=4\pmod{13}.$$

Related Question