Modular Arithmetic/Fermat's Little Theorem

From testwiki
Revision as of 15:36, 27 August 2023 by imported>Wikigucoder
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:NavigationTemplate:Calculus/DefTemplate:ExampleRobox Let us look at the powers of a number under modulo arithmetic. We'll look at:

3,32,33,34...

and we're going to look modulo a prime number p. First we'll choose p=7. We could work out each number and then reduce, e.g.

34=3×3×3×3=814mod7
35=3×3×3×3×3=2435mod7

but it is quicker just to work out 3n+1 from 3n like so:

31=33mod7
32=3×3=92mod7
33=2×3=66mod7
34=6×3=184mod7
35=4×3=125mod7
36=5×3=151mod7
37=1×3=33mod7
38=3×3=92mod7


it is quite clear that the pattern is repeating. That's because 361mod7. Even without doing the calculation it is clear that the pattern has to repeat somewhere. There are at most 7 different possible numbers for 3nmod7 so if we calculate it for n=1,2,3,4,5,6,7,8 there has to be a repeated answer somewhere in there.

Note: This is a use of the pigeonhole principle - there are more pigeons than pigeonholes, so one pigeonhole must contain two pigeons. If you are interested, click on the pigeon icon to read more about the pigeonhole principle:

Template:Phprinciple

Once a number is repeated the sequence from there on must be the same as before, from the first occurrence of that number. We can even see that we will get a 1 followed by a 3 as where the repeat first happens. Why?

Suppose we have some repeated number, in other words 3a3a+b with a and b positive numbers. Then 3a3a3b and we can divide both sides by 3a to get 13b, i.e. a repeat that happens sooner. Just a little care is needed. In modulo arithmetic it is not always allowed to divide by a common factor. We're allowed to do that division here because we earlier established it for modulo a prime using Euclid's algorithm. We know that 3nmod7 is not zero since otherwise 3 would be a factor of 7 and 7 is prime.

Template:Robox/Close


Something to watch out for with modular arithmetic, we cannot just reduce numbers wherever we see them. For example working mod7, the exponent of 8 in 38 cannot just be replaced by 1 because 3831mod7. The ones to watch are in exponents. In expressions like 1000xmod7 and (1000+x)mod7 it is fine to replace the 1000 to get 6xmod7 and (6+x)mod7 or even xmod7 and (x1)mod7.



Template:ExerciseRobox

  • Now your turn. Do exactly the same thing as in the example, but this time for p=11

Template:Robox/Close


There is nothing special about 3 here. We could do exactly the same exercise for other numbers a with a=1,2,4,5or6. We might reach an1 sooner, we definitely will for a=1, but we would still have a(p1)1(modp).

We will prove this several ways. The reason for making such a meal out of proving it, is that it helps to see different ways of proving a result. In this case, it's mainly a way to show the different notation that can be used. The third variant of the proof will also introduce the concept of multiplicative functions, which will be important later on.

Template:Trig/NAV