The theorem itself.

According to Dickson (and others; see Bibliography) Fermat first announced his theorem in a letter to Mersenne, June (?), 1640.

Fermat's 'little' theorem. Let p be prime, and a be any integer with [Maple Math] (mod p ), then

[Maple Math] (mod p )

In non-congruence language: let p be any prime, and a be any integer not divisible by p , then [Maple Math] leaves remainder 1 on division by p .

A small hand performed illustration. Let [Maple Math] and [Maple Math] , then [Maple Math] = [Maple Math] * [Maple Math] .

Maple examples (the meaning of each command should be clear).

> restart;

> p[1] := nextprime(120);

[Maple Math]

> a[1] := 2;

[Maple Math]

> 57 mod 5; # the remainder 57 leaves on division by 5

[Maple Math]

> a[1]^(p[1] - 1);

[Maple Math]

> a[1]^(p[1] - 1) mod p[1];

[Maple Math]

> p[2] := nextprime(10^20 + rand());

[Maple Math]

> a[2] := rand(); # Maple has a 12-digit random number generator:

[Maple Math]

> a[2] mod p[2];

[Maple Math]

> a[2]^(p[2] - 1);

Error, integer too large in context

That expected, and intentional output can be overcome by using the so-called square-and-multiply method which is incorporated into a Maple command by the use of '&' as follows. (The mathematics of that command, the so-called square-and-multiply method - modular exponentiation - is covered in a Maple worksheet at my web site. It forms part of my 3rd year course on Number Theory and Cryptography.)

> a[2]&^(p[2] - 1) mod p[2];

[Maple Math]

And let's just see the values [Maple Math] :

> 2&^(p[2] - 1) mod p[2];

[Maple Math]

> 3&^(p[2] - 1) mod p[2];

[Maple Math]

> 5&^(p[2] - 1) mod p[2];

[Maple Math]

>

Anyone who already knows some Number Theory will understand why I didn't check that

[Maple Math] (mod [Maple Math] )

It is an automatic consequence of

[Maple Math] (mod [Maple Math] )

as indeed

[Maple Math] (mod [Maple Math] )

is a consequence of

[Maple Math] (mod [Maple Math] ) and [Maple Math] (mod [Maple Math] )

and now consider this:

> p := 10^80*rand()^2 + 20! + 2*rand() + 127;

[Maple Math]

> length(p);

[Maple Math]

Could that p be a prime? Let's see: if p is prime then automatically we have [Maple Math] (mod p ), etc.

So, let's calculate;

> 2&^(p - 1) mod p;

[Maple Math]

>

Ah! So it isn't, since the output was not 1. I hope you realise how powerful that calculation is, for in a microsecond it has determined that the above p is composite.

Question . But what if the output had been '1'? What then? Would it follow that p is prime? If you don't already know the answer to that question, then you might like to think about it before you read Section 4 (Primality Testing).

Software Note . The above fast computation might appear impressive, but for seriously large numbers - ones with hundreds of thousands, or several million digits - Maple is, quite simply , absolutely useless . For seriously large numbers a user must avail of remarkable public-domain programs like:

prime95.exe (George Woltman's GIMPS project)

Everyone will know that George's program has found - on
desktop computers - the last four record sized Mersenne primes (most earlier ones had been found on CRAY supercomputers), the most recent of which is the only known prime with more than a million digits.

proth.exe (Yves Gallot's Proth project)

In July 1999 - using Yves' program - I had the good fortune to find the 115130 digit prime 3*
[Maple Math] (the then [Maple Math] largest known prime), and a factor of the (then, and still ) largest known composite Fermat number:
[Maple Math]

That prime proved to be a divisor of the
generalised Fermat numbers:

[Maple Math] ,
[Maple Math] ,
and
[Maple Math]

each of which were new records for their type (of which the last two still stand).

Prime Form (Chris Nash's original version, based on Yves Gallot's Proth library)

NewPGen (Paul Jobling's sieve program, based on Yves Gallot's Proth library)

PRP (George Woltman's probabilistic primality program - which actually uses Fermat's little theorem - to be used in conjunction with NewPGen, and Proth.exe). A faster version - PRP2 - also by GW, exploits the recent Intel Pentium IV chip

In May 2001 - using a combination of Yves Gallot's proth, Paul Jobling's NewPGen, and George Woltman's PRP - I also had the good fortune to find the 275,977 digit prime 3*
[Maple Math] (the then [Maple Math] largest known prime; it may still be, but these prime rankings have a habit of not lasting for a long time!) That prime proved to be a divisor of the generalised Fermat numbers:
[Maple Math]
and
[Maple Math]

The first of those broke the previous record (above), and the second established a new record for its type.

Last month - here in Klagenfurt - Manfred Toplic found the 246767 digit prime 5*
[Maple Math] (the [Maple Math] largest known prime), and a divisor of the generalised Fermat number:
[Maple Math]

pfgw (the Chris Nash managed program; the 'pf' is 'Prime Form,' the 'g' is 'Gallot,' and the 'w' is 'Woltman.')

That list is not complete; one should consult the web sites of Chris Caldwell (exclusively devoted to prime numbers) or Keith Matthews (which covers Number Theory in general). Those two sites are the "cream of the cream."

Contact details 

After August 31st 2007 please use the following Gmail address: jbcosgrave at gmail.com


This page was last updated 18 February 2005 15:08:45 -0000