The Cunningham Project is an long running endeavour to factorise numbers of the form

bfor^{n}± 1b=2, 3, 5, 6, 7, 10, 11, 12,up to high powers ofn. It started in 1925, long before the electronic computer age. The collection of factors from scattered source and the collation and verification of the factors was a difficult challenge at the time.At that time a computer was the name given to "a person that computed". These days most people know a computer as the box that sits on their desk in the study. Most people will reach for a calculator once their numbers go into double figures and are unlikely to ever experience the pleasure and sense of accomplishment the hand calculator would derive from factoring a large number.

On the other hand, more time can be spent on the development of factoring algorithms and less time on the drudgery of hand multiplication and division. This has led to the invention of many high powered primality/factoring algorithms and methods that more fully utilise the computer power available today on the desktop. With the improvement from two directions at once, the factorisation of these large numbers has grown in leaps and bounds.

I stumbled across the The Cunningham Project Site one day and was pleasantly surprised what I discovered there. There are several up to date Cunningham factorisation tables provided. They are organised into three files:

- The main table of factors pmain*.txt for C
^{±}(b,n). In this table large primes and composite cofactors are aliased as Pn and Cn where n denotes the length of the decimal expansion of the number.- Appendix appa*.txt, a table of the full decimal expansion of the Pn's.
- Appendix appc*.txt, a table of the full decimal expansion of the Cn's. These numbers are the unfactored composite cofactors. They are known to be composite, but no factors are yet known.
- The * above is a short date - currently it is 1104 denoting November, 2004.
The site also has "wanted lists" for the composite cofactors whose factorisation is considered most desirable. These are usually the smallest Cn in each table. There is a page of latest developments containing factors not yet added to the above 3 text files and even a slow factor calculator for factoring a single Cunningham number at a time. They also include a link to Factorizations of b^n+-1, b=2,3,5,6,7,10,11,12 Up to High Powers. At this site you can obtain free of cost, a full PDF copy of the book.

This book is an excellent resource with detailed explanation on how to read the tables and use them to manually generate other factors not explicitly tabled - for instance Aurifeuillian factorisation and the factorisation of C

^{−}(b,n) for even n.There is also a discussion of the development and history of factoring techniques and primality tests from the start of the project in 1925 right up to the current day. Primality proof summaries are given and a list of 348 references to key papers in the area of factorisation/primality.

To facilitate my understanding Cunningham numbers and their factorisation I decided to write a program that would read in all the table data and generate all the factors for each base b and exponent n. I wanted to see the full factorisations in place without having to look to earlier exponents for factors. In the published tables all references to unfactored composites and primes in any given factorisation need to be looked up in separate appendices. They don't provide factorisations for even exponents. I don't see why even exponents are any different than odd composite exponents, both can be algebraically factored. While the prime exponent cases are the most interesting (and difficult) to factor, I see no reason not to include all the factorisations for easy reference.

In their original state, the tables are not exactly computer friendly so I decided that some preprocessing of the data to a more rigid record based format more was in order prior to loading into my program.

Just for fun I decided the program should generate both the standard text based output plus a more interesting HTML format with some hyperlinking and colour coding to move between the factors and spot primes and composite cofactors.

This program reads preprocessed Cunningham Database files of factored Cunningham numbers and produces both text files and HTML files of complete factorisations - all factors are produced in "all their deserved glory".

My implementation is not completely straightforward. There are some interesting use of data structures, in particular a linked list for the main factor table with dynamic memory allocation used for factor and exponent strings. The alternative of using static structures would have been very wasteful due to the huge variation in sizes of factors (as small as 1 digit, as large as 200+ digits).

The data/process flow is as follows (change MMYY to the appropriate short date)

- Preprocess pmain<date>.txt using the command line
"awk -f pmain.awk pmainMMYY.txt > pmain.in"- Preprocess appaMMYY.txt using the command line
"awk -f appa.awk appaMMYY.txt > appa.in"- Preprocess appcMMYY.txt using the command line
"awk -f appc.awk appcMMYY.txt > appc.in"- Modify html_header.txt to suit (the HTML wrapper).
- Compile, link and run this C program.
- Have look at the 16 text file and 16 HTML file outputs. Enjoy!
Here is the source code and awk scripts for those interested. Please give me credit and send me a lot of money if you get rich and famous using any ideas from the source :-)

- Here is the entire source code zip pack. Alternatively select individual items below.
- My awk scripts used to generate canonical input from the originals:
- The HTML output wrapper
- The C source

There are 32 output files made up of 16 text files and 16 HTML files. These are all linked in the table below.

## Canonical Representation Of Factorisations

- Factorisations are given from smallest to largest factor, with a period '.' separating factors.
- Multiplicity of factors is indicated with the carat '^' in ascii tradition for the text version of the tables but not the HTML version.
- The backslash '\' is used to indicate continutation of a line, the decimal digit representation of the number does not stop but continues on the next line as if no break had occured. This can sometimes make for bad breaks, but such is life.
## Notation Used In The Tables

The following colour coding and hyperlinking conventions are adopted:

- Composite exponents are in black. C
^{±}(b,n) is composite in this case.- Prime exponents are coloured
orange. C^{±}(b,n) is usually composite in this case too.- A prime C
^{±}(b,n) is colouredgreen- this is a rare jewel and ignoring n=1 cases can only occur in C^{−}(2,n) with n prime (Mersenne primes) and C^{+}(b,n) with b even and n a power of 2 (Generalised Fermat primes).- Factors in an expression coloured
redare unfactored. They are known to be composite but there are currently no known factors.- Hyperlinked numbers occur in previous exponents in the same or related table.
- #Fac is the number of (non distinct) prime factors in an expression.
- A dashed #Fac means that more prime factors exist but they are unknown due to an unfactored composite in the expression.

You can download the entire factor packs to your local machine to save your internet bandwidth. These tables are fairly large (up to 1MB in size).

Cunningham Factors Text Output Pack (0.9 MB) Cunningham Factors HTML Output Pack (1.4 MB)

Mostlate breaking information can be obtained from the sites listed below. They should be your first stop if you want the latest, up to date factorisation status.

- ECCM Page At GIMPS
- ECCP Page At GIMPS
- Paul Leyland's Cunningham Updates (link no longer available).
- Cunningham Site - New Factors

The C

^{−}(b,n) numbers are composite when n is composite. This is the result of an algebraic factorisation that many will recognise as the geometric series formula they learned in high school. More formally, if m,n are postive integers and m divides n, then b^{m}- 1 divides b^{n}- 1. The proof of this amounts to observing that x -1 divides x^{a}- 1 for natural numbers x and a because

...(GS)...

x^{a}- 1 = (x - 1)(1 + x + x^{2}+ ... + x^{a-1})Thus if m divides n then n=m*a for some integer a>=2. The result follows by setting x=b

^{m}in the above identity.A corollory to the above result is that because x - 1 divides x

^{a}- 1, a necessary condition for x^{a}- 1 to be prime is that x=2 and a is prime.If you have trouble understanding the above result, try multiplying out the terms on the right hand side and notice that all but the largest and smallest terms cancel out in pairs. Trying doing an induction proof if you are really skeptical.

This is also a result of an algebraic factorisation that many will recognise from high school. First observe that if

bis odd thenCis an even number (odd powers are odd and odd plus odd is even). Thus it is clear that if^{+}(b,n)bis odd then 2 dividesC.^{+}(b,n)Next, notice that if

nhas an odd factorathenn=m.afor some integermandC

^{+}(b,n) = b^{n}+ 1 = (b^{m})^{a}+ 1Now use a variation of (GS) above obtained by replacing

xbyx/yandabynand multiplying by through byywe have the alternate identity^{a}

...(GS2)...

x^{a}− y^{a}= (x − y)(x^{a−1}+ x^{a−2}.y + x^{a−3}.y^{2}+ ... + x.y^{a−2}+ y^{a−1}).Substituting in

y=−1givesx

^{a}− (−1)^{a}= (x + 1)(x^{a−1}− x^{a−2}+ x^{a−3}+ ... + (−1)^{a−2}.x + (−1)^{a−1})which yields in the case of odd

ax

^{a}+ 1 = (x + 1)(x^{a−1}− x^{a−2}+ x^{a−3}+ ... + −x + 1).Finally comparing the first and last equations above and setting

x=byields the result that^{m}bdivides^{m}+ 1Cwhen n has an odd factor^{+}(b,n)abecause

...(SOTS)...

b^{a.m}+ 1 = (b^{m}+ 1)(b^{m(a−1)}− b^{m(a−2)}+ b^{m(a−3)}+ ... − b^{m}+ 1).A corollory to the above result is that if

b>1andCis prime, then a necessary condition is that^{+}(b,n)bis even andn=2for some integer^{m}m>=0. Not surprisingly, numbers of this form have been given their own name - The Generalised Fermat Numbers and are denoted byGF(n,b) = bwhere^{N}+ 1N = 2. When^{n}GF(n,b)is prime it is referred to as a Generalised Fermat Prime.As a final remark, the polynomial

xis the^{N}+ 12cyclotomic polynomial and is thus irreducible over the rationals. This means it cannot be written as the product of two positive degree polynomials with rational coefficients. In other words, there is no further algebraic factorisation possible. This does NOT mean that further integer factorisation is not possible though when^{n+1}thxis set tob.

Another algebraic factorisation that is particularly useful when n is even, is the difference of two squares. Simply stated, a

^{2}− b^{2}= (a − b)(a + b). If n=2m say, then this formula gives:

...(DOTS)...

C^{−}(b,n) = C^{−}(b,2m) = b^{2m}− 1 = (b^{m})^{2}− 1^{2}= (b^{m}− 1)(b^{m}+ 1) = C^{−}(b,m).C^{+}(b,m).In other words C

^{−}(b,n) can be factored into a product of a smaller Cunningham numbers (one from the same table and one from a related table).

Consider the following identity:

...(AF2+)...

2^{2h}+ 1 = L.M where L = 2^{h}− 2^{k}+ 1, M = 2^{h}+ 2^{k}+ 1, h = 2.k − 1.This factorisation was discovered by Aurifeuille for one value and the general form subsequently discovered by Lucas. There are other Aurifeuillian factorisations, I list some of them below. There is much to be learned in this area. You can easily establish the above identity by multiplying out the right hand side and simplifying. A deeper explanation however will require a study of both Cyclotomic and Aurifeuillian polynomials. It turns out that they can be explained well in terms of roots of unity − you will have to start up your search engine to find more details.

...(AF3+)...

3^{3h}+ 1 = (3^{h}+ 1).L.M where L = 3^{h}− 3^{k}+ 1, M = 3^{h}+ 3^{k}+ 1, h = 2.k − 1....(AF5−)...

5^{5h}− 1 = (5^{h}− 1).L.M where L = T^{2}− T.5^{k}+ 5^{h}, M = T^{2}+ T.5^{k}+ 5^{h}, T = 5^{h}+ 1, h = 2.k − 1....(AF6+)...

6^{6h}+ 1 = (6^{2h}+ 1).L.M where L = T^{2}− T.6^{k}+ 6^{h}, M = T^{2}+ T.6^{k}+ 6^{h}, T = 6^{h}+ 1, h = 2.k − 1....(AF7+)...

7^{7h}+ 1 = (7^{h}+ 1).L.M where L = T^{3}− B, M = T^{3}+ B, T = 7^{h}+ 1, B = 7^{k}(T^{2}− 7^{h}), h = 2.k − 1....(AF10+)...

10^{10h}+ 1 = (10^{2h}+ 1).L.M where L = A − B, M = A + B, A = 10^{4h}+ 5.10^{3h}+ 7.10^{2h}+ 5.10^{h}+ 1, B = 10^{k}(10^{3h}+ 2.10^{2h}+ 2.10^{h}+ 1), h = 2.k − 1....(AF11+)...

11^{11h}+ 1 = (11^{h}+ 1).L.M where L = A − B, M = A + B, A = 11^{5h}+ 5.11^{4h}− 11^{3h}− 11^{2h}+ 5.11^{h}+ 1, B = 11^{k}(11^{4h}+ 11^{3h}− 11^{2h}+ 11^{h}+ 1), h = 2.k − 1....(AF12+)...

12^{3h}+ 1 = (12^{h}+ 1).L.M where L = 12^{h}− 2^{h}.3^{k}+ 1, M = 12^{h}+ 2^{h}.3^{k}+ 1, h = 2.k − 1.