For all ideas taken from other sources (books, articles, internet), the source of the ideas ismentioned in the main text and fully referenced at the end of the report.

All material, which is quoted essentially word-for-word

from other sources, is given inquotation marks and referenced.

Signed ............................................................. Date...................................

Tony Skyner

Perfect Numbers

3/30

Chapter 1: Perfect Numbers

1.1

Introduction

It is not known when Perfect Numbers where first discovered, or when they were studied.However, it is thought that they may even have been known to the Egyptians, and may haveeven been known before. Although the ancient mathematicians knew of the existence ofPerfect Numbers, it wasthe Greeks who took a keen interest in them, especially Pythagorasand his followers (O’Conner and Robertson, 2004).

The Pythagoreans found the number 6 interesting (more for its mystical and numerologicalproperties than for any mathematical significance), as it is the sum of its proper factors, i.e.

6 = 1 + 2 + 3

This is the smallest Perfect Number, the next being 28 (Burton, 1980). These two numbersalso had religious significant ascribed to them, as 6 is the number of days it took the ChristianGod to

create the world, and 28 is the number of days in a Lunar Cycle. ST

Augustine evenwent as far to say

Six is a number perfect in itself, and not because god createdall things in 6 days; rather the converse is true. God createdall things in 6 days because the number is perfect.

This he wrote in the City of God (cited in Ellis, 2004).

Though the Pythagoreans were interested in the occult properties of Perfect Numbers, theydid little of mathematical significance with them. It was around 300BC, when Euclid wrotehisElements

that the first real result was made. Although Euclid concentrated on Geometry,many number theory results can be found in his text (Burton, 1980). We shall considerEuclid’s result in a moment, but first, lets define Perfect Numbers more properly.

There are numerous ways to define Perfect Numbers, the early definitions being given interms of

aliquot parts. This author defines Perfect Numbers as:

A Perfect Number n, is a positive integerwhich is equal to the sum of its factors,excluding n itself.

However, we can define Perfect Numbers in terms of therestricted divisor function

s(n),which is the sum of the proper factors ofn. Thus, ifn

is a Perfect Number

n

=s(n)

Alternatively, we can use the divisor functionσ(n), which is thesum of all the factors ofn.So, ifn

is perfect, we have

n

=s(n) =σ(n)–

n



σ(n) = 2n

This latter definition is more widely used, and so will be the convention for this text. Beforecontinuing, we shall state a lemma concerning the sigma notation:

Lemma 1

σ(nm) = σ(n)σ(m) (multiplicative) if and only ifn

andm

are relatively prime

Proof: We shall not prove this, as it is slightly involved. A proof can be found in Burton(1980).

Tony Skyner

Perfect Numbers

4/30

Returning to Euclid’s result. The result of interest isProposition IX.36 ofElements

(Dickson,1952, cited inWeisstein, 2004), which is quoted as

If as many numbers as we please beginning from a unit beset out continuously in double proportion, until the sum ofall becomes a prime, and if the sum multiplied into the lastmake some number, the product will be perfect.

It should be noted at this point that the Greeks knew of only 4 Perfect Numbers:

6, 28, 496, 8128

The work by Euclid remained the only significant study of perfect numbers for some time,until around 100AD when Nicomachus of Geras wroteIntroductio Arithmetica. In this text,he divided numbers into three groups:



Deficient numbers: sum of proper factors is less than the number



Abundant numbers: sum of proper factors is greater than the number



Perfect numbers: sum of proper factors is equal to the number

He also presented 5 conjunctures, all of which he left unproven, and they are:

1)

Then-th perfect number hasn

digits

2)

All perfect numbers end in

6 and 8 alternately

3)

All perfect numbers are even

4)

Euclid’s algorithm generates ALL perfect numbers

5)

There are infinitely many perfect numbers

Tony Skyner

Perfect Numbers

5/30

Nicomachus made no attempt to prove these conjectures, and it seems that he made them withonly Euclids algorithm and the 4 known perfect numbers (Ellis, 2004). The first conjecture isreadily disproved, by considering the 5th

perfect number:

212(213

–

1) = 33550336

and the second is disproved by considering the next perfect number:

216(217

–

1) =8589869056

which also ends in 6. However, we shall salvage something from this conjecture: we shallshow that all even perfect numbers end in either 6 or 8 (see proposition 7).

As for the other 3 of Nicomachus’ conjectures, we shall show that Euclid’s algorithmgenerates all even perfect numbers (see theorem 4). However, we do not know if there are anyodd perfect numbers (none have been found, and therefore it seems highly unlikely that thereare any). Similarly, Nicomachus’ 5th

conjecture also remains unanswered.

It is slightly worrying that, even though these conjectures were unproven (and, as will beseen, mostly false), they were taken as truth for over 1500 years. No real progress was made,until 1690, when Fermat announced the discovery of one of the greatest theorems in NumberTheory, what is now known asFermat’s Little Theorem

(O’Connor & Robertson, 2004). Withthis theorem, Fermat was able to make a lot of progress into verifying perfect numbers.

At this point, efforts into searching for perfect numbers had shifted, when Euler proved theconverse of Euclid’s theorem (see theorem 4), and so the search was on for values ofn

suchthat 2n

–

1 is prime. Numbers of this form became known as Mersenne numbers, and we shalldiscuss them later. For now, many results concerning perfect numbers were discovered (manyof them by Euler), and so now we shall study these in the following section.

Tony Skyner

Perfect Numbers

6/30

1.2

Perfect Number Results

As was mentioned earlier, Euclid produced a theorem that gave the means of finding evenperfect numbers.

Below is a theorem from Euler (cited in Burton, 1980) that states that allperfect numbers are of the form stated by Euclid.

Theorem 4

n

= (2r

–

1)2r-1

is an even perfect number if and only if 2r

–

1 is prime.

Proof:

Adapted from Burton (1980).

We havealready proven theonly if

part in proposition 3.

Now suppose thatn

is aneven

perfect number. Thenn

is of the form

n

= 2r-1m

where, in this context,m

= 2r

–

1. Asn

is perfect

σ(n) = σ(2r-1m) = 2n

From lemma 2 above, and the multiplicatively of σ, we have

σ(2r-1m) = σ(2r-1) σ(m) = (2r

–

1) σ(m)

So, as σ(n) = 2n

asn

is perfect, we have

(2r

–

1) σ(m) = 2n

= 2r(2r

–

1)

σ(m) = 2r

= (2r

–

1) + 1

Thus, σ(m) is the sum ofm

and 1 only, which means that these are the only factors ofm, so, by the definition of primality,m

must be prime.

We now have a definite means of finding perfect numbers. We simply have to determinewhen 2r

–

1 is prime, and then we automatically have a

perfect number. The next lemmalimits the choice ofr.

Lemma 5

Ifak

–

1 is prime, wherea> 0 andk

≥ 2, thena

= 2 andk

is also prime.

Proof:

Cited in Burton (1980).

It is well known that

ak

–

1 = (a

–

1)(ak-1

+ak-2

+ … +a

+ 1)

Asa

> 0, we have

ak-1

+ak-2

+ … +a

+ 1 ≥a

+ 1 > 1

Thus, asak

–

1 is prime, and the second factor is greater than 1, we must have

a

–

1 = 1

a

= 2

Now, ifk

is composite andk

=rs

where 1<r

and 1 <s, then

ak

–

1 = (ar)s

–

1 = (ar

–

1)(ar(s-1)

+ar(s-2)

+ … +ar

+ 1)

But, asr,s

> 1 anda

= 2 from above, both factors are > 1, which is a contradiction tothe primality ofak

–

1, so by contradiction, we must havek

prime.

So we now know that Mersenne numbers (numbers of the form 2n

–

1) are prime only if theindex is prime. However, we know that this is not always the case as, for example

211

–

1 =2047 = 23.89

Tony Skyner

Perfect Numbers

7/30

The following Lemmas and Propositions quite interesting.

Lemma 6

16t

≡ 6 mod(10) for allt

ℕ.

Proof:

We shall proceed by induction. Clearly, fort

= 1 we have

161

= 16 ≡ 6 mod(10)

Now suppose that the assertion is true fort

=k, that is

16k

≡ 6 mod(10)

Then we must show that 16k+1

≡ 6 mod(10), so

So, by induction, the assertion is true.

Proposition 7

An even perfectnumbern

ends in the digit 6 or the digits 28.

Proof:

Partially cited in Barton (1980).

We are required to prove that

n

≡ 6 mod(10) orn

≡ 28 mod(100)

Asn

is an even perfect number, we know it has the form

2p-1(2p

–

1)

where, from Lemma 5,p

is prime. Clearly, ifp

= 2,n

= 6 and the assertion holds. Wecan thus confine the proof top

> 2, and so we shall continue in two parts, according asp

takes the forms 4m

+ 1 or 4m

+ 3.

Forp

= 4m

+ 1, we have

n

= 24m(24m+1

–

1) = 28m+1

–

24m

= 2∙162m

–

16m

Lemma 6 gives 16t

≡ 6 mod(10) for allt

ℕ, thus

n

≡ 2∙6–

6 ≡ 6 mod(10)

Now, ifp

= 4m

+ 3, we can note that

2p-1

= 24m+2

= 4∙16m

≡ 4∙6 ≡ 4 mod(10)

Moreover, forp

> 2, we have 4|2p-1

and so we have that the number formed by the lasttwo digits of

2p-1

is divisible is divisible by 4, and the last digits is 4. So, thepossibilities are:

2p-1

= 4, 24, 44, 64, or 84 (mod(100))

But this implies

2p

–

1 = 2∙2p-1

–

1 ≡ 7, 46, 87, 27, or 67 (mod(100))

Thus, we have

n

= 2k-1(2k

–

1) = 4∙7, 24∙47, 44∙87,

64∙27, or 84∙67 (mod(100))

Tony Skyner

Perfect Numbers

8/30

To complete the proof, we must now show that each of the above is congruent to 28modulo 100. The first (4∙7 = 28) is clearly true.

Now, working over the integers mod(100), we have

The remaining three can be verified in a similar manner, and is left to the reader.

Proposition 8

All even perfect numbers are triangular numbers.

Proof:

Asn

is an even perfect number, we have

n

= 2p-1(2p

–

1)

Ifn

is also a triangular number, then it must be of theform

n

= ½k(k–

1)

The proof is completed by simply setting

k

= 2p

Then

½k

= 2p-1

andk

–

1 = 2p

–

1

Lemma 9

Letn

be a positive integer, and lets(n) be the sum of the digits ofn. Then, working inthe integers mod(9),s(n) =n.

Proof:

Consider the digit representation ofn:

n

=a1a2a3…ar

Then

s(n) =a1

+a2

+ … +ar

To calculaten

mod(9), consider the following:

n

mod(9) =n

–

9k

=n

–

10k

+k

for somek. Now setk

=a1a2…ar-1

(n

with it’s last digit removed), then

n

mod(9) = (a1a2a3…ar-1ar)

–

(a1a2a3…ar-10) +a1a2…ar-1

=ar

+a1a2…ar-1

Continuing this process, we end up with

n

mod(9) =ar

+ar-1

+ … +a1

=s(n)

As required



Tony Skyner

Perfect Numbers

9/30

Theorem 10

With the exception of 6, if the digits of an even perfect numbern

are summed, andthen the digits of that number summed and so on until a single digit is obtained, thenthat digit is 1.

Proof:

Adapted from Cadwell (2004).

From the above lemma, we only need to show that all even perfect numbers arecongruent to 1 mod(9). Consider the group ofintegersZ/9Z. It is trivial to show that 2has order 6 in this group, that is

26

≡ 1 mod(9)

So, we only need to consider the numbers 2r-1(2r

–

1) forr

= 1, 2, 3, 4, and 5. We havealready excluded 6, and clearly no prime number is congruent to 4 mod(6), thus itremains to show that the numbers

20(21

–

1), 22(23

–

1), 24(25

–

1)

are all congruent to 1 mod(9). This is left to the reader to verify

As an example of the above theorem, consider the perfect number

496

4+9+6 = 19

1+9 = 10

1+ 0 = 1

1.3

Other Forms of Perfect Numbers

1.3.1

Odd Perfect Numbers

One of the greatest unsolved problems of classical mathematics is the answer to a very simplequestion: are there any odd perfect numbers? At the moment, the answer is “we don’t know,we haven’t found any yet”, and at the same time we cannot prove that there aren’t any. In1908, Turcaninov (cited in Burton, 1980) showed that if any did exist, then thy must have atleast 5 distinct primes, and would be more than 2∙106. Modern computers have shown that, iffact, if any exists, they would have to be greater than agoogolplex

(that is, 10100).

Although no example of an odd prime has been found,

there has been a fair amount of theoryabout them (though most beyond the scope of this text). The following theorem from Eulerwas one of the first developments on the issue.

Theorem 11

Ifn

is an odd prime number, then

wherethep,q1, …qr

are distinct odd primes, andp≡ α ≡ 1 mod(4).

Proof:

Cited in Barton (1980).

Let

be the prime factorisation ofn. Sincen

is perfect, we have

Asn

is an odd integer, eithern

≡ 1 mod(4) orn

≡ 3 mod(4). In either case

2n

≡ 2 mod(4)

Thus σ(n) = 2n

is divisible by 2, but not by 4. This implies that one of the factorsabove, say σ(pα), must be even (but not divisible by 4), while the remaining

In 1888 Syvester proved that an odd perfect number must have at least 4 distinct primefactors. This result has improved to 8 distinct prime factors, and 29 non-distinct prime factors,and the number would have to be more than 300 digits long,and it smallest prime factor mustbe greater than 106

(cited in Ellis, 2004)

It is very curious how so much work, and so many theorems andproofs, have been createdconcerning a set of numbers that do not appear to exist at all. It is ironic the above theorem,along with many others, place conditions on the existence of these numbers, and there is avery good chance that in the near future, someone will produce a proof that they do not existat all!

Tony Skyner

Perfect Numbers

11/30

1.3.2

Multiply Perfect Numbers

A Multiply Perfect Number (or Pluperfect Number) is a number such that the sum of it’sproper factors is an integer multiple of itself. In terms of the sigma notation, multiply perfectnumbers are defined as

thus, 120 is a 3-fold pluperfect number (or is a multiply perfect number, abundancy 3).

There are many other “types” of perfect numbers; some examples are listed below:



Quasiperfect numbers

These are defined as

σ(n) = 2n

+ 1

Any number, whose sum of its proper factors is greater than itself, is known as anabundant number. Thus, quasiperfect numbers are the least abundant numbers.However, none are known to exists (if they do they must be greater than1035)(Weisstein, 2004)



Almost perfect numbers

These are defined as

σ(n) = 2n

–

1

They are also calledslightly defective numbers, and the only ones known to exist arethe powers of 2, i.e. 2, 4, 8, 16, 32, … (Weisstein, 2004)



Hyperperfect numbers

These

are defined as

n

= 1 +k(σ(n)–

n

–

1)

Note that settingk

= 1 gives the usual definition of a perfect number. Many of theseare known, and some theory is available, but we shall not consider them further (formore information, see Weisstein–

1 (mainly from Fermat’s new tools, like hisLittle Theorem), and in 1644 producedCogitata Physica-Mathematica, in which Mersenne stated that 2p

–

1 is prime for the valuesofp

2, 3, 5, 7, 13, 17, 19, 31, 67, 127, 257

and composite for all other values ofp

< 257. It was clear to Mersennes peers that he couldnot have possibly tested all these values, and as it is, his assertion was incorrect (cited in Ellis,2004).

Some of the numbers had already been determined for primality. In 1536, Huddrichus Regius(a prolific mathematician who has almost been forgotten in modern times) produced in hisUtruisque Arithmetices

the following factorisation:

211

–

1 = 2047 = 23∙89

This may seem a small accomplishment, but it must be remembered that this calculationwould probably have been done in Roman Numerals

(with the aid of an abacus), as Arabicnumbers had not yet won over (Burton, 1980). Regius also verified thatp

= 13 produced thenextMersenne Prime

(although Mersennes name had not yet been ascribed to them),producing the 5th

perfect number:

212(213

–

1) = 33, 550, 336

At this time, the only means for determining the primality of a number was to try and dividethrough by primes smaller than it’s square root. But very few primes (relatively speaking)were known, and so in 1603, Pietro Cataldi produced a

table of primes less than 5150, anddetermined that 217

–

1 is prime (cited in Ellis, 2004).

Further work by Euler, Fermat, and other great mathematicians of the time, produced anumber of works on the subject, but little progress towards Mersennes conjuncture was made.The 19th

Century saw some more interesting developments, though some mathematicianswere sceptical. In 1811, after proving that 231

–

1 is prime, Barlow (1980, in hisTheory ofNumbers) concluded by saying that his prime “… is the greatest

that ever will be discovered;for as they are merely curious, without being useful, it is not likely that any person will everattempt to find one beyond it” (cited in Burton, 1980). Clearly Barlow seriouslyunderestimated the human curiosity, which willalways strive to discover greater finds,regardless of the cost or whether the findings have any practical value. However, in this case,Barlow was even further from the truth, as many important applications of Mersenne Primesexists, especially in CodingTheory, and Internet Banking, where the large primes are used insecurity tests.

The most important development came later that Century, when Edward Lucas determinedthat 2127

–

1 is prime without actually computing the number. This was the largest known

forthe next 75 years. In 1947, an adaptation of Lucas’methods (what is known as the Lucas-Lehmar Test, see §3.2.2) was used along with high-speed computers to finally check all ofMersennes predictions. All 55 primes less than 257 were tested, and it was

found thatMersenne had made 5 errors: he had included 267

–

1 and 2257

–

1, and excluded 261

–

1, 289

–

1 and 2107

–

1 (Burton, 1980).

Tony Skyner

Perfect Numbers

13/30

Today, the search for large Mersenne primes goes on, the last decade mainly dominated byGIMPS, the Great Internet Mersenne Prime Search (more on them later), and the search foranswer to some of the many questions surrounding Mersenne primes, like, ‘is there an infiniteor finite number of them?’ It was conjuncture that double Mersenne primes (i.e. a Mersenneprime whose index is a Mersenne Prime) are always prime, but alas, in 1953, with the aid ofhigh speed computers, it was found that

is composite (Ellis, 2004).

The search for Mersennce Primes (and thus perfect numbers) has led to some of the mostimportant developments in mathematics, not only in Number Theory, but in other areas suchas computational mathematics, calculus and statistics. Fermat discovered his Little Theoremas a result of searching for Mersenne Primes.

Tony Skyner

Perfect Numbers

14/30

2.2

Mersenne Results

The search for Mersenne Primes (and thus perfect numbers) is not at all trivial. The first stepis to reduce the list of possible prime indices. We proceed with the following three theoremsthat lead to a corollary that is paramount in the search. We shall denote a Mersenne number

2n

–

1 by Mn.

Theorem 12

Ifp

> 2 is prime, thenp

divides one of

or, but not both.

Proof:

Fermat’s Little Theorem gives

2p-1

–

1 ≡ 0 modp

sop

divides 2p-1

–

1, but

Sop

divide at least one of the two factors. As the factors differ by 2, andp

> 2,p

cannot divide both.



This theorem does not tell us much about Mersenne primes, but it is a good motivation for thenext theorem, which is proved in a very similar manner.

Theorem 13

Ifp

> 2 andq

= 2p

+ 1 are prime, then eitherq|Mp

orq|(Mp

+ 2), but not both.

Proof:

Cited in Barton (1980).

Fermat’s Little Theorem gives

2q-1

–

1 ≡ 0 modq

Factorising the LHS gives

which is the same as saying

Mp(Mp

+ 2) ≡ 0 modq

This givesq|Mp

orq|(Mp

+ 2) but not both, for the same reason as in theorem 11.



This could be used to verify if Mp

is composite, however the amount of work to determinewhetherq

divided Mp

or Mp

+ 2 makes this theorem a little difficult to use. This next theoremdetermines whenq

divides Mp

and Mp

+ 2.

Tony Skyner

Perfect Numbers

15/30

Theorem 14

Ifq

= 2n

+ 1 is prime (n

> 0), then

1)

q|Mn

provided thatq

≡1 mod 8

2)

q|(Mn

+ 2) provided thatq

≡3 mod 8

Proof:

The proof shall not be presented here, as it requires Legendre Symbols, and followsfrom the previous theorem. A proof can be found in Barton (1980).



Note that the two possibilities in the above theorem exhaust all possibilities forq

(i.e. all oddvaluesq

could take). Now we know whenq

divides Mp. The following corollary condensesthe above theorems into an easy test.

Corollary 15

Ifp

≡ 3 mod(4) andq

= 2p

+ 1 are both odd primes, thenq|Mp.

Proof:

Cited in Barton (1980)

An odd prime is either of the form 4k

+ 1 or 4k

+ 3. So

p

= 4k

+ 3

q

= 8k

+ 7

q

≡ 7 ≡-1 mod 8

and

p

= 4k

+ 1

q

= 8k

+ 3

q

≡ 3 mod 8

From the previous theorem, both cases result inq|Mp.



This can be easily applied, and in fact removes a large number of composite Mersennenumbers. For example, ifp

= 11 thenq

= 23 (which is prime). But 23–

3∙8 = 23–

24 =-

1, sothat 23 ≡-

1 mod 8. Thus, by Corollary 15, 23 divides 211

–

1.

We now have a list of “possible” Mersenne Primes. To verify ifa Mersenne number is indeedprime, it is sometimes easiest (especially with small numbers) to exhaust possible primefactors. The following 2 theorems show that any prime factor of a Mersenne Number is of aprecise form (an example will follow to show howthis can be used).

Theorem 16

Ifp

is an odd prime, then any prime divisor of Mp

is of the form 2kp

+ 1 (or isequivalent to 1 mod (2p)).

Proof:

Adapted from Barton (1980)

Letq

be any prime divisor of Mp, and consider the ring of integers modq

(it can

beshown that this is a field, and is denoted byZ/pZ). Asq

is a divisor of 2p

–

1, we havethat

2p

≡ 1

We need to show thatp

is the smallest integer such that this holds (that is, to show that2 has orderp

as an element of the group of integers modq

under multiplication). So,suppose there exists a smallest integerk

such that

2k

≡ 1 modq

As a consequence of Lagrange’s Theorem, we havek|p. Now, we cannot havek

= 1,otherwise

21

≡ 1

1 ≡ 0 modq



q|1

which is an impossible situation. From this, and the primality ofp, we must have

k

=p.

Tony Skyner

Perfect Numbers

16/30

From Fermat’s Little Theorem, we have

2q-1

≡ 1 modq

and so, again Lagrange’s Theorem, we havek|q-1. Ask

=p, this givesp|q-1, or

q

–

1 =

pt



q

=pt

+ 1

Finally, we note that ift

were odd, thenpt

+ 1 would be even. Butq

must be an oddprime (asp

> 2, because we know that M2

is prime), sot

must be even. That is

q

= 2kp

+ 1

for some integerk.

Theorem 17

Ifp

is an odd prime, then any prime divisorq

of Mp

is of the form

q

≡1 mod 8

Proof:

Cited in Barton (1980)

We have seen a special case of this in theorem 13. Suppose thatq

is odd, so

q

= 2n

+ 1, and is a prime divisor of Mp. Set

then

a2

–

2 = 2p+1

–

2 = 2Mp

≡ 0 modq

Now, raising both sides of the congruenceto the n-th power gives

aq-1

=a2n

≡ 2n

modq

Asq

is an odd integer, anda

is even, we have

hcf(a,q) = 1

aq-1

≡ 1 modq



2n

≡ 1 modq



q|Mp

This can now be compared to theorem 13, which gives usq

≡1 mod 8.

To demonstrate this, consider M21

=

221

–

1 = 2097151. To determine whether this is prime,we could check for prime factors less than its square root (which is <1449). The only primesthat satisfy the previous two results, and are less than 1449 are:

127 337 463 631 673 967 1009 1303

In fact, direct computation shows that both 127 and 337 are factors of 221

–

1, but the rest arenot. Thus, 221

–

1 is not a Mersenne prime.

One of the many unanswered questions concerning Mersenne numbers is whether they aresquare-free, that is, whether they have any factors which are squares (i.e. is Mq

divisible byp2, for some primep).

If 2p-1

–

1 is divisible byp2

thenp

is called a Wieferich prime. The following propositionshows that if a Mersenne number is divisible by some prime squared, then that prime is aWieferich prime

Tony Skyner

Perfect Numbers

17/30

Theorem 18

Ifp

> 2 (prime) divides 2q

–

1 for someq

> 2, thenp

is a Wieferich prime.

Proof:

Cited in Cadwell (2004)

From Theorem 16, we have thatp

= 2kq

+ 1 for somek. Thus, asp

divides 2q

–

1 wehave:

Raising the congruence to the 2k-th power gives 2p-1



1 mod (p2), so thatp

is aWieferich prime, as required.

It is not known whether the set of Wieferich primes is finite or infinite, but Wieferich primesare very rare: there are only two less than 3×1012, and they are

1093 and 3511

(Hardy & Wright, 2002). Because of this, it is fairly reasonable to consider Mersennenumbers to be square free.

The following proposition is an adaptation of a proof from Hardy & Wright (2002).

Proposition 19

1093 is a Wieferich prime.

Proof:

Setp

= 1093. Forp

to be a Wieferich prime, we must havep2

divides 2p-1

–

1. This isthe same as saying

2p-1

–

1 ≡ 0 modp2

So, working over the integers mod 10932, we have

37

= 2187 = 2p

+ 1

314

= (2p

+ 1)2

= 4p2

+ 4p

+ 1 ≡ 4p

+ 1

and

214

= 16384 = 15p

–

11

228

= 225p2

–

330p

+ 121 ≡-330p

+ 121

so that

32.228

≡-2970p

+ 1089 =-2969p

–

4 ≡-1876p

–

4

and so

32.226

= (-1876p

–

4)/4 =-469p–

1

Hence, by the binomial theorem

314.2182

≡-(469p

+ 1)7

≡-3283p

–

1 ≡-4p

–

1 ≡-314

from the working above. Thus we have

2182

≡-1

21092

≡ 1modp2



2p-1

–

1 ≡ 0modp2

ٱ

Tony Skyner

Perfect Numbers

18/30

Chapter 3: Primality Testing

3.1

Introduction

The search for Mersenne primes may seem of very little importance, but (as mentionedearlier) large primes are of great importance, as well as of major interest to the mathematicalcommunity. The efforts employed in their discovery have lead to some of the majordevelopments in mathematics (e.g. Fermat’s Little Theorem). So why do we

need largeprimes? With the modern age of computers, systems of encoding data need to be incredibledifficult to “break”, but fairly easy to use. That’s where primes come in. Simple put, if wemultiply two very large prime numbers together, and then transmit the result, then there areonly two possible factors for the decoder to find (so no ambiguities). But if a hacker finds thisresult, they will find it very difficult to randomly “guess” the factorisation. However, ascomputers get more advanced, the possibility of someone doing this increases. The onlysolution is to use larger primes.

As we shall see in the next section, finding Mersenne primes is not easy. However, the task offinding them has been taken up by GIMPS (theGreatInternetMersennePrime

Search). In1995, the programmer George Woltman started to gather up all the databases of Mersenneprime data, and wrote an optimised version of the Lucas-Lehmar test (see §3.2.2). He wasmotivated by Slowinski, who works for Cray computers. He wrote a computer program(based on the Lucus-Lehmar Test), and set the computers in all the Cray Labs to run the testin their spare time (Cadwell, 2004).

In 1997, Scott Kurowski set up PrimeNet, which helped distribute Woltman’s software(which is completely free)

to as many people as possible. So, with a handful of experts, andthousands upon thousands of amateurs (all running the program in their computers spare time,and sending the data to GIMPS via the internet–

the process complete automated), the searchfor

Mersenne Primes has entered an entirely new level (Cadwell, 2004).

GIMPS is currently the world record holder for the largest prime, which Josh Findleydiscovered on 15th

May 2004. The number he discovered is

224 036 583

–

1

This number has 7,235,733 digits, and is the 41st

Mersenne prime. GIMPS uses a highlyoptimised program, using some of what we have already seen, the Lucas-Lehmar test belowand Fast Fourier Transforms (FFT). However, we shall now consider some simpler tests forfinding Mersenne Primes.

Tony Skyner

Perfect Numbers

19/30

3.2

Common Tests for Mersenne Primes

3.2.1

Using Fermat’s Little Theorem

Fermat’s Little Theorem is a powerful Number Theory tool, and can be used to an extent totest for primes. As a reminder, his theorem states:

Theorem 20

Ifa

andp

are relatively prime, thenap-1

≡ 1 mod(p)

So, if we have some numbern

and we want to test for primality, we could just pick a numberrelatively prime ton, raise it to then-1 power, and see if it is congruent to 1 mod(n). If it isn’tthenn

is definitely not prime (as the above is true for allp

anda). However, if it is, then wewould need to check another number. Clearly we would have to check 2, 3, … (n-1). If thecongruence holds for all these, thenn

must be prime!

However, there is a class of composite numbers that satisfy Fermat’s Little Theorem for allintegersa. These are calledCarmichael numbers. Though they are fairly rare (the first few are561, 1105, 1729, 2465), it has been proven that there is an infinite many of them, and soFermat’s Little

Theorem is not completely reliable (Cadwell, 2004). However, we could useFermat’s Little Theorem to determine whether a given Mersenne isprobably

prime.

An attempt at writing a Maple Procedure for using Fermat’s Little Theorem was made, butwith little

success. The procedure produced was only effective at testing primes smaller than231

–

1; clearly this is not very good (although, the procedure may not have been written in themost optimal way).

The next method we shall look at tells usexactly

if the

given Mersenne number is prime ornot.

3.2.2

Lucas-Lehmar Test

One of the most useful and used test for determining the primality of Mersenne numbers is theLucas-Lemar Test. This test tells absolutely whether a given Mersenne number is prime ornot. Most modern tests use adaptations of this theorem. We shall consider this theorem andit’s proof (Lucas-Lehmar, 1930, cited in Caldwell, 2004), but first we shall prove a shortlemma:

Lemma 21

Ifsn

=sn-12

–

2 ands1

= 4, then

Proof:

Weshall prove by induction. Let

and, then

i)

Letn

= 1, then

which is true.

ii)

Now assume that the lemma is true forn

=k, i.e.

Tony Skyner

Perfect Numbers

20/30

We shall show that

We have thatsk+1

=sk2

–

2, so

as

and. So by induction,the lemma is true.

ٱ

Theorem 22

Letp

be an odd prime, thenMp

(thepth

Mersenne) is prime if and only ifs(p

–

1)

≡ 0modMp, where

s1

= 4 andsn

=sn-12

–

2

Proof:

Cited in Cadwell (2004)

We shall prove sufficiency only. Let

and, then from the abovelemma, we have

Thus,Mp

dividessp-1

means that the exists an integerR

such that

or, multiplying through by

and subtracting 1, we have

(1)

We shall now prove by contradiction. SupposeMp

is composite, and chooseq, one ofMp’s prime factors which is less than. Now consider the group

This is the field of integers modq

with3 adjoined, or all the numbers of the form

which are invertible. Note thatG

has at mostq2

–

1 elements. Now,asMp

has a factorq, looking atw

modq

makes (1) become

Thusw

is an element ofG

of order 2p. Since the order of an element of a group is atmost the order of the group itself, we have

2p

≤q2

–

1 <Mp

= 2p

–

1

which is a contradiction, thus proving the theorem.

Tony Skyner

Perfect Numbers

21/30

This test has many great advantages, as it is easily programmed into appropriate software(such as Maple, see §3.4). To demonstrate its use, consider M5

(= 31). The first 4

values in theiteration are

S1

= 4

S2

= 42

–

2 = 14

S3

= 142

–

2 = 194

S4

= 1942

–

2 = 37634 = 31∙1214

So, as S4

is divisible by 31, 31 is prime (which, of course, we already knew). This examplealso demonstrates the tests main (and maybe even only) weakness: the huge values that areintroduced. In §3.4, we shall see how this procedure breaks down for largerp.

3.3

Formula For Primes

In 1976, the mathematicians James Jones, Diahachiro Sato, Hideo Wada and Douglas Weinpublished the paperDiophantine Representation of the Set of Prime Numbers, in which theyproduced a formula that generates a set of numbers that is identical to the set of primenumbers (cited in Bowyer, 2004). Their work was based on the work done by C.P. Willans,who published a paper in 1964 entitled “On Formulae for the Nth Prime Number”. In thispaper he produced the following theorem (adapted for the purposes of this text).

Theorem 23

For all positive integersx, we define the functionf

as

where⌊⌋

is the usual floor operator. Iff(x) = 1, thenx

is prime, and iff(x) = 0 thenx

iscomposite.

Proof:

We shall not prove this. A proof can be found in the above-mentioned paper, found intheMathematical Gazzette

Volume 48, pages 413 to 415.

From this result, Willan was able to establish the following formula for thenth

prime number:

In the next section, we shall see how the above test, along with others, performs atdetermining if a Mersenne number is prime, or not.

Tony Skyner

Perfect Numbers

22/30

3.4

Maple Procedures For Testing Mersenne Primes

3.4.1

Lucas-Lehmar Test

We shall now look at the Lucas-Lehmer Test, and develop a modified version, which will bemore suited to programming in Maple. Let us restate the original theorem

Letp

be an odd prime, thenMp

(thepth

Mersenne) is prime if and onlyifs(p

–

1)

≡ 0 modMp, where

s1

= 4 andsn

=sn-12

–

2

This can easily be programmed into Maple as aprocedure, though for largerp, the hugenumbers involved pose problems. To tackle this, we shall makea small alteration to thetheorem above, using the following lemma:

Lemma 24

Letf(X) be a polynomial of degreen,p

a prime number, ands

a positive integer,wherep

does not divides

or any of the coefficients off(X). Then

f(s) ≡f(s

modp) modp

Proof:

We shall prove this forf(X) a quadratic polynomial

f(X) =a1X

2

+a2X

+a3

wherea1,a2

anda3

are integers. The idea is easily extended to the general case.

Lets

modp

=d

(i.e.s

≡d

modp), thenk

such thats

=d

+kp, so

Now, asa1,a2,a3,k

are integers, all terms involvingp

are ≡ 0 modp. Also, byelementary Algebra,p

does not divide any other terms asp

does not divideai

i

ord,so

f(s) modp

=a1d2

+a2d

+a3

=f(d)

butd

=s

modp, so

f(s) modp

=f(s

modp)

f(s) ≡f(s

modp) modp

ٱ

In particular, ifsn

=f(sn-1) =sn-12

–

2

sn

≡f(sn-1

modp) modp

We can now use this to restate the Lucas-Lehmer Test in the following:

Corollary 25

Letp

be an odd prime, thenMp

(thep-Mersenne) ifs(p

–

1)

≡ 0, where

s1

= 4 andsn

= (sn-12

–

2) modMp

Proof:

This follows directly from the Lucas-Lehmer Theory (theorem 22), and the abovelemma

ٱ

Tony Skyner

Perfect Numbers

23/30

This modified version of the Lucas-Lehmer Test is now more suited for programming, as theiteration is greatly scaled down

at each step, avoiding such large numbers forming. This willgreatly reduce the runtime required to perform the iteration, as well as reducing the memoryrequirements (vital for testing larger primes). For example, to testM31

requires over 50Megabytes,and takes over 200 seconds when using the original test. However, using themodified version requires negligible amounts of memory, and is performed almost instantly.

The syntax inserted to Maple to perform this procedure is:

>LLT:= proc(n)

local i,x,k;

Digits:=2;

x[0]:=4;

for i to n do

x[i]:= (((x[i-1])^2)-2) mod(2^n-1);

for k to 45 do

if 1000*k=i then print(evalf(i/n*100)) else true;

end if;od;od;

if type(x[n-2],poszero)=false then print("LLT Testcomplete: Not Prime");

else

print("LLT Test

complete: Prime");

end if;

end;

The third, eighth and ninth lines could be omitted, as they display the percentage of theprocess completed after every 1000 iterations. A print screen of a typical output can be foundin the Appendix (§4.1).

The procedure was run for all the Mersenne Prime up toM44497

using the University of BristolSchool of Mathematics computers, and the time and memory demands were recorded. Thetable below summarises the results of this test.

Num †

Mp

†

Digits †

Time (s)

Mem (Mb)

27

244497

–=N=ㄳ㌹N=㤷㤮㈪=㔱㈪=㈶=O23209

–=N=㘹㠷=㜳ㄮT=㈱O=㈵=O21701

–=N=㘵㌳=㔰ㄮR=ㄷN=㈴=O19937

–=N=㘰〲=㐰ㄮ4=ㄵN=㈳=O11213

–=N=㌳㜶=㄰㐮N=㔲⸱=㈲=O9941

–=N=㈹㤳=㜹⸴=㐱⸲=㈱=O9689

–=N=㈹ㄷ=㜴⸳=㌹⸶=㈰=O4423

–=N=ㄳ㌲=ㄴ⸶=ㄲ⸰=ㄹ=O4253

–=N=ㄲ㠱=ㄴ⸲=ㄱ⸲=ㄸ=O3217

–=N=㤶9=㠮U=㠮U=ㄷ=O2281

–=N=㘸S=㌮P=㘮〰=ㄶ=O2203

–=N=㘶S=㌮P=㔮㔶=ㄵ=O1279

–=N=㌸P=㈮O=㈮㠱=ㄴ=O607

–=N=ㄸN=㈮O=㈮㠱=ㄳ=O521

–=N=ㄵN=M=M=ㄲ=O127

–=N=㌹=M=M=ㄱ=O107

–=N=㌳=M=M=㄰=O89

–=N=㈷=M=M=9=O61

–=N=ㄹ=M=M=U=O31

–=N=㄰=M=M=T=O19

–=N=S=M=M=Tony Skyner

Perfect Numbers

24/30

6

217

–=N=S=M=M=R=O13

–=N=4=M=M=4=O7

–=N=P=M=M=P=O5

–=N=O=M=M=O=O3

–=N=N=M=M=N=O2

–=N=N=Returned false

Table 1: Results of Primality Testing using the modified Lucas-Lehmar Test († Sloane, cited inCadwell, 2004). *Iterations terminated at 42% completion due to insufficient resources, and valuesgiven at time of termination.

Note thatM2

returned false, asp

must be greater than 2, and thatM44497

could not be verified,as the demands on the system were too great. So the procedure is fairly effective, but breaksdown at larger primes. The procedure would also be useless at finding Mersenne primes, as itwould take years to check all possible indexes. We shall consider a more efficient algorithmin §3.4.3.

3.4.2

Formula for Primes

Next we shall consider the formula for prime numbers discussed in §3.3. The theorem was:

For all positive integersx, we define the functionf

as

where⌊⌋

is the usual floor operator. Iff(x) = 1, thenx

is prime, and iff(x) = 0thenx

is composite.

This is also fairly simple to program into Maple, using the following code:

this test is very poor at testing Mersenne Primes. This isbecause this test is not specific to Mersenne Primes, but can be used for all primes (whereasthe Lucas-Lehmar Test is for Mersenne Primes only).

Tony Skyner

Perfect Numbers

25/30

3.4.3

Conglomerate of Tests

Our final task is to produce an efficient algorithm for finding Mersenne Primes (and thusPerfect Numbers). We shall need all of the theory we have seen to do this. We shall start bycreating a procedure that uses this number theory to ensure that the index of the Mersennenumber is of the correct form. We shall do this in the following order:



First we check that the index is prime (Lemma 5, §2.1)



Then we shall check to see if the index is 2 or 3 (as some of the theorems and test donot apply for these values).



Finally, we shall apply Corollary 15 (§2.1).

This was written as a Maple procedure using the following syntax:

>MNT:=proc(n)

global R;

local m;

m:=(2^n)-1;

R=0;

if isprime(n)=false then

R:=1;

print("MNT Test complete: Index not Prime");

elif n=2 or n=3 then

R:=1;

print("MNT Test complete: This number is PRIME");

elif n mod(4)=3 and isprime(2*n+1)=true then

R:=1;

print("MNT Test complete: NOT PRIME. Index is not of thecorrect form");

else;

R:=0;

print("MNT Test complete: index n is of correct form");

end if;

end;

The use of the global R is for the final test, and indicates whether or not the test has returnedtrue of false. A print screen of a typical output can be found in the Appendix (§4.3).

The next step is to test our Mersenne number for small factors. For this we shall needTheorem 16 and 17 (§2.1), which gives us the form that the factor should take. Using this, thefollowing Maple code was written:

>TFT:= proc(n, r)

global R;

local d,m,x,i;

m:=(2^n)-1;

x:= false;

for i to r while x= false do

d:= (2*i*n)+1;

if (d mod(8)) = 1 or (d mod(8)) =-1 then

x:=type(m/d,integer);

if x=true then print("TFT Test complete: NOT PRIME.Trivial Factor found:");

print(d);

R:=1;

else;

end if;

end if;

Tony Skyner

Perfect Numbers

26/30

od;

if R=1 then

else;

print("TFT Test complete:No trivial factors");

end if;

end;

So we now have everything we need. The final step is to bring the three tests together. Thefollowing code is the Mersennetest procedure:

>Mersennetest:= proc(n)

global R;

local T;

MNT(n);

if R=1 then

else;

TFT(n, 100);

if R=1 then

else;

LLT(n);

end if;

end if;

end;

A print screen of a typical output can be found in the Appendix (§4.4). To see how effectivethis procedure is, a list of increasing random positive integers was generated (using MicrosoftExcel), and the procedure was applied to it. The table below outlines the results.

n

Prime?

Reason For Failing

Time (s)

Mem (Mb)

11

No

Incorrect form

0

0

13

Yes

N/a

0.4

0

14

No

Index not prime

0

0

15

No

Index not prime

0

0

17

Yes

N/a

1.1

0

29

No

Trivial Factor = 233

0

0

79

No

LLT

1.0

0

117

No

Index not Prime

0

0

211

No

Trivial Factor = 15193

0

0

469

No

Index not Prime

0

0

757

No

LLT

2.7

0

2257

No

Index not Prime

0

0

5003

No

Incorrect Form

0

0

9941

Yes

N/A

83.6

38.2

14721

No

Index not Prime

0

0

21347

No

Trivial Factor = 170777

0.3

0.1

29157

No

Index not Prime

0

0

Table 3: Results of the Mersennetest procedure.

The table above should help convince the reader how rare Mersenne Primes are. It should alsobe clear how useful using Number Theory and Trivial Factor Tests, before applying theLucas-Lehmar Test, are: only two of the composites had to be verified with the Lucas-LehmarTest.

Tony Skyner

Perfect Numbers

27/30

Appendix

3.5

The Lucas-Lehmar Test

Figure 1: A typical output of the Lucas-Lehmar test, as programmed into Maple 8.

3.6

Formula For Primes Test

Figure 2: A typical output of the Formula For Primes Test, as programmed into Maple 8.

Tony Skyner

Perfect Numbers

28/30

3.7

Other Test

Figure 3: A typical output of the Mersenne Number Theory Test, as programmed into Maple 8.

Tony Skyner

Perfect Numbers

29/30

Figure 4: A typical output of the Trivial Factors Test, as programmed into Maple 8.

3.8

Conglomerate of Tests

Figure 5: A typical output of the MersenneTest procedure, as programmed into Maple 8.

Tony Skyner

Perfect Numbers

30/30

4

References

Bowyer, A. Accessed 19th

October 2004. “Formula For Primes”.

www.bath.ac.uk/~ensab/Primes/

Burton, D.M. 1980.Elementary Number Theory. First Edition. Allyn and Bacon, Inc. London