New Primality Criteria and Factorizations
New Primality Criteria and Factorizations
620
satisfies the congruence aN~l = 1 (mod TV), 1 <a < TV- 1, i.e., TVis a "pseudoprime"
base a. (Since a is chosen in advance, it is extremely rare that TVis composite when it
is found to be a psp base a.)
Theorem 1. Let TV— 1 = n p¡ '. If for each p¡ there exists an a¡ such that TVis
a psp base a¡,but a¡ p'^ 1 (mod TV), then TVis prime.
Proof. Let e¡ be the order of a¡ (mod TV). Since e¡ | TV- 1, but e( '('(TV- l)lp¡,
then pi '\e¡. But for each i, e¡ | 4>(N), so that p¡ '\ 0(TV),which implies TV- 1 |0(TV).
Hence, TVis prime. Q.E.D.
Remarks. 1. Theorem 1 indicates that if for any p¡ a base a¡ can be found for
which both hypotheses are satisfied, then that p¡ is settled once and for all. (See [4, p.
89].) This is in contrast to the somewhat less satisfactory situation in earlier theorems
(see Lehmer [6] and Lucas [11]) where a single base a is used for which the hy-
potheses must be satisfied for all p¡.
2. The computations for each p¡ can be done efficiently by calculating
// there exists an a for which a(N~' )/2 = - 1 (mod TV),but aml2 £ -1 (mod TV),
then TVis prime.
Proof. Let e be the order of a (mod TV). Then e | TV- 1. But, using the same
argument as in the proof of Theorem 2, am £ 1 (mod TV), so e \ (TV- l)/p. Hence,
p | e, and since e | 0(TV), then p | </>(TV).
Also,
0(TV)|/Vn(/z¿
- 1) = (mp + l)n(H(.- 1),
so p | n(«(. - 1), or p | n, - 1 for some i, say /' = 1. Thus, «, = 1 (mod 2p). But
TV= 1 (mod 2p), which implies TV/«X= 1 (mod 2p). On the other hand, since «, >
2p + 1 > \/TV, then 1 < TV/Wj< VtV"< 2p + 1. Therefore, the only possibility for
TV/Hjis 1, so TVis prime. Q.E.D.
Remark. This theorem reduces the amount of testing because the prime factors
of m can be ignored. Also, note that p need not be the largest prime divisor of TV- 1,
as TV= 31 and p = 3 shows.
Throughout the rest of this paper the notation TV— 1 = F1Rl will be used,
where F1 is the even factored portion of TV- 1, R x is > 1, and (Fl, R x) = 1.
Theorem 4 (Pocklington [14]). If for each prime p¡ dividing Ft there exists
an a¡ such that TVis a psp base a¡ and (a¡ ' — 1, TV) = 1, then each prime divisor
of N is = 1 (mod F¡).
Proof. Let « be a prime divisor of TV,and e{ be the order of a¡ (mod n). Then
«,111-1. Also, of'1 = 1 (mod n), so e¡ |TV- 1. On the other hand, (a?~l)IPi -
1, n) = 1, so e¡ -f (TV— \)¡p¡, which implies p¡ ' \e¡, where p¡ ' IlFx. Hence, for each
i, p"''|« - 1, so that F, |n - 1. Q.E.D.
Remark (R. DeVogelaere). In verifying the hypotheses of this theorem, only
one GCD computation is necessary: First find an a¡ such that a¡ ' — 1 = b¡ £ 0
(mod TV) for each /; then calculate the product II b¡ = c (mod TV); and finally, if c ^
0, compute d = (c, TV).
If d i= 1, then TVis composite and a factor has been found. Also, if c = 0, then
some b¡ has a prime factor in common with TV.
For convenience of reference put:
(I) . For each prime p¡ dividing Fl there exists an a¡ such that TVis a psp base a¡
and{af-ï)lp'-\,N)=\.
Corollary 1. Assume (I). If Fx > \/N, then TVis prime.
Remark. Corollary 1 is an improvement over Theorem 2 in that the primality
test can be completed as soon as the factored part of TV- 1 exceeds the unfactored
part. This saving in time is offset only to a slight degree by the amount of computing
needed to calculate the required GCD's. It will be the main goal of the rest of this
paper to continue to reduce the amount of auxiliary factorization, as in this case,
through the introduction of various conditions which require a small amount of com-
puting time as compared to the factoring time eliminated. In this regard, the next
theorem is a considerable improvement on Corollary 1, since TV— 1 need only be fac-
tored to the point where FI > (TV/2)1/3 rather than Fx > s/Ñ. A further reduction is
possible if m is chosen to be > 1. The cost of this reduction is at most the time needed
to calculate (r2 — 8s)Vl and the trial division of XFj + 1 into TVfor m — 1 values of X.
Theorem 5. Assume (I) and let m be > 1. When m > 1, assume further that
\Fl + 1 \ Nfor 1< \<m. If
where r and s are defined by R¡ = (TV- 1)/Fj = 2Fls + r, 1 < r < 2Fv then TVis
prime if and only if s = 0 or r2 - 8s ¥=D. (r^O since R1 is odd.)
Proof. The theorem will be proved in the equivalent form: TVis composite if and
only if s =¿0andr2 - 8s = D.
(i) (=>). From Theorem 4 it follows that all factors of TVare 1 (mod F{).
Thus, since TVis composite,
(6) Rl={N-\)¡Fl=cdFl+c + d
it follows that
(8) c + d=r (mod 2Fj),
where c + d - r > 0, since r is the least positive remainder (mod 2F1 ). On the other
hand, (c - m) (d - m) > 0 implies cd > m(c + d) - m2, so that
To see this, it is sufficient to consider the smallest values of the coefficients, i.e.,
when c = d = e = m. Then
TV= (mFj + l)3 = (wFj + l)[m2F2 + 2/nF, + I] > (mF1 + 1)[4F,2 + 2mFl + 1]
Corollary 2. Assume (I) and (II), and let n be a prime divisor of N. Then n =
1 (mod pFx), where p is some prime divisor of Rx depending on n.
Proof. Since (Fx, Rx) = 1, the corollary follows from Theorems 4 and 6. Q.E.D.
Corollary 3. Assume (I) and (II). If all the prime factors of Rx are > Bx
and BXFX> \/W, then TVis prime.
Proof. From Corollary 2, n — 1 > pFx > BXFX> %/TV,which implies TVis prime.
Q.E.D.
Remark. The new feature on Corollary 3 is that Bx appears in the inequality for
TV. The number Bx is quite different from Fx, since Fx contains the "discovered"
factors of TV— 1, while Bx gives the information (not immediately verifiable) that the
prime factors of Rx are greater than or equal to Bx. (This latter assumes that no factor
of TV— 1 has been overlooked, as it might be if the computer were not working
properly.)
The next theorem, which improves on Corollary 3, uses formulas relating to the
hyperbola x2 —y2 = TV,in a way similar to what was done implicitly in the proof of
Theorem 5.
Lemma 1. If either 0<a<b < \/TV or y/Ñ < Z>< a, then b + TV/Z?
<a+
TV/a.
Proof. The conclusion follows from (a-1 - ¿>_1)(TV- ab) > 0. Q.E.D
Theorem 7. Assume (I) and (II), and also that the prime factors of Rx are > Bx.
If
where r and s are defined by Rx = 2Fxs + r, 1 < r < 2FX, then TVis prime if and
only ifs = 0orr2-8s^D.
Proof. The theorem will be proved in the equivalent form: TVis composite if
and only if s + 0 and r2 - 8s = D.
(i) (=>). From Theorem 4 all the factors of TVare 1 (mod Fx ). Since TVis
composite, it can be written asTV= nw = x2 -y2 = (x -y)(x +y) = (cFx + l)(dFx + 1),
c, d > 1, where n is the smallest prime factor of TVand w > 1. Then TV= cdF2 + (c + d)Fx
+ 1 and 2x = (c + d)Fx +2. But R, = cdF\ + c + d, and since R x is odd and F, is
even, then c + d is odd, so that cd is even, say cd = 2g. Then TV= 2gF\ + 2x - 1,
so 2x = F1Ä1 + 2 - 2gF\ = Fx(2Fxs + r) + 2 - 2gF\ = (s - g)2F\ + rFx + 2.
Let X = s - g. Then from rFx + 2 < Ft(2F, - 1) + 2 < 2F2 it follows, since x >
0, that 0 < 2x = 2XF2 + rFx + 2 < 2F2(X + 1), so that X > 0. On the other hand,
2x=n+w=n+ N/n, and from Corollary 2, n = 1 (mod pFj), son > pFj + I >
BXFX + 1. Hence, using Lemma 1 and (10), 2XF2 + rF, + 2 = 2x = n + N/n <
(T^F, + 1) + TV/(FjFj + 1) < (£,F, + 1) + 2F2 + (r - Ax)Fj + 1 = 2F,2 4- rFx
+ 2. Consequently, X < 1. Thus, X = 0 and rFx + 2 = 2x = (c + d)Fx + 2, which
implies r = c 4- d. Then 2Fts + r = Rx —cdFx + c + d gives 2s = cd ^ 0.
4. Lucas Sequences. The primality theory which was established in the preceding
sections was based on factoring TV- 1. In this section and the two that follow, a
primality theory is developed which depends on factoring TV+ 1.
Central to the TV+ 1 theory are the divisibility properties of certain second order
recurring sequences known as Lucas sequences. These properties, which contain Fer-
mat's theorem as a special case, will be reviewed here along with several other results that
apply to the later development. Some of the more familiar results will be given with-
out proof (see Lucas [10] ).
The Lucas sequences {Uk} and {Vk} are defined recursively by the formulas:
Uk+2=PUk+l-QUk, k>0, u0 = o, ux = \,
(14) 2Vr+s=VrVs+DUrUs.
In what follows the notation et will be used for the value of the Jacobi symbol
(D/t).
The main divisibility properties of these sequences are contained in the theorems
and corollaries which follow.
Theorem 8. (a) Ifp^2Q,thenUD_e y p =0 (mod p).
(b) Ifp\2QD,then V =2Q^-^p)n (modp).
= 2Q(l'ePy2{l-(Q/p)} (modp),
from which the theorem immediately follows. Q.E.D.
Corollary 4. Ifp\2QD, then p\ V^p_e )/2 if and only if (Q/p) = - 1.
Proof. This follows from Theorem 8, (11), Theorem 9, and (13). Q.E.D.
From Corollary 4 a test for compositeness can also be obtained.
Corollary 5. Suppose N^QDand that (Q/N) - - I. IfN^V{N_e )/2,
then TVis composite.
Remark. The residues of U and Vm (mod TV), which must be computed in
these theorems, can be computed with about triple the work of computing a power
(mod TV). An efficient method for calculating Vm (mod TV) is discussed in detail in
Lehmer [8, p. 129]. To compute Um (mod TV) one can use the formulas: U2k =
UkVk and V2k = Vk - 2Qk for doubling the subscript, and U2k+X =
(PU2k + V2k)/2 and V2k+X = (DU2k + PV2k)/2 for a "side-step" of 1. The sequence of
doublings and side-steps to be followed is easily obtained from the binary expansion of m.
Theorem 8 shows that an odd prime p, not dividing Q, will divide at least one
term of {Uk}, namely Ue . The least positive k such that p\Uk is called the "rank
of apparition" of p (or just "rank") and is denoted here by p(p). (If several Lucas
sequences {U^} are being employed, then p¡(p)will denote rank in {Uj¡.')}.) This
notation will also designate the rank of a composite number.
Theorem 10. Suppose p\2Q and that pa IIUp(p), a > 1. Then Pa+ßWmp(p)
if and only if p^Wm.
Remark. If a prime p divides Q but does not divide P, then p-\Uk, k> \.
When (TV,Q) = 1, the following formula for p(TV) can be obtained from Theorems
8(a) and 10:
P(N)= LCM [pKKmaX(7ra,',0)l
(b) N\Ukifandonlyifp(N)\k.
It will be convenient to introduce a function, similar to the Euler 0 function,
which will be of use in deriving the primality theorems.
Definition. If (TV,D) = 1 and TV= W¡=, n¡*, let
^(N,D)=2y-°f=i
n («/-o»?'-1-
'
(This function is not a generalization of the Euler function, because of the power of 2
in front of the product.)
Theorem 12. // (TV,D) = 1, then t//(TV,
D) = TV- ejy */aw? on/y //TVz'sprime.
Proof. (•*=). Clear from the definition of \¡i.
(=>). The statement will be proved in the equivalent form:
If TVis composite, then <//(TV,
D) =£TV- eN.
Case 1. s = 1, i.e., TV= n7, ?> 2. 77ie«
i//(TV,
D) = (n - e„)n7" ' = TV- TVe„/wJ=N- eN.
which divides
LCM[(«,.- e„>7/_1] = 2 LCM[H(n,- e_ )«7'_1],
which divides
O5) TVI7(,'>
JV| K(AT+l)/2'
but (for qt > 2)
1 K(AT+1)/2V
then TVis prime.
Proof. From (11) and (15) it follows for each i that TV|UJp+x, so p,(TV)exists
and p,(TV)|TV
4- 1 by Theorem 11(b). Also, for each qf > 2, TVt ^$4.,),,.; for, if
Wl U(N+Xyq. for some i, then from Theorem 11(b),
(17) NIU0)
where s = (q¡ - l)/2. But then, using (15), (14), and (17), it follows that
n = 9 I/O') = ? pO')
U ~ ZK(AT+l)/2 ZK[i(iV+l)/<îI.+ (iV+l)/2rî(.]
V/(TV,
D)\Nn (»,■
- e ) = (mi?- 1) ft (»/- e .),
/=i ' /=i
so (71FI¿_j («¿ - en ), or q | «¿ - en for some /', say i = 1. Thus « j = en (mod 2<7).
Also,TV= - 1 (mod 2q), so N/nx = - en (mod 2q). But «j > 2q - 1 > \/TV,which
implies 1 <TV/«j <\/TV <2q — 1. Thus, the only possibility in the interval
[1, 2(7- 1) is that TV/«j= 1, i.e., TVis prime. Q.E.D.
Throughout this section the notation TV4- 1 = F2R2 will be used, where F2 is
the even factored portion of TV4- \,R2 is > 1, and (F2, R2) = 1.
Theorem 16 (Morrison [12]). Consider the set U of Lucus sequences {U^}
with the given discriminant D for which (D/N) = — 1. If for each prime q¡ dividing F2
there exists a Lucas sequence in U such that N\U^+ and (U\ll, , TV) = 1, then
each prime divisor n of N is = en (mod F2).
Proof. It is clear from Lemma 2 that p¡(N)\N 4- 1, which implies p¡(n)\N + 1.
Since n \ t/g+, , Theorem 11(b) implies p,.(«) \(N 4- \)lq{. Thus, q\l \ Pi(n),
where q. ' IIF2. Also, p¡(n)\n - en, so q¡ ' |n - e„ for all i, that is, F2 \n - en. Q.E.D.
For convenience of reference put:
(III) For each prime q¡ dividing F2 there exists a Lucas sequence {iftO} with
discriminantD for which (D/N) = - 1, TV|UJp+i, and (U$+ x)/q , N) = 1.
Corollary 8. Assume (III). If F2 > V?V 4- 1, then TVis prime.
Proof. n + l>n-en>F2> \¿N + 1, which implies TVis prime. Q.E.D.
In what follows the notation Fx = F,/2 andF2 = F2\2 will be used.
Theorem 17. Assume (III) and let m be > \. When m > I, then assume further
it follows that
On the other hand, (c - m)(d + m)> 0 implies that cd> (d - c)m + m2, so that
= [(í-r)F24-l][(í4-r)F2-l],
where the factors on the right are > 1, since s =£ 0. Q.E.D.
Remark. The value of r in Theorem 17 is chosen to be the absolutely least re-
mainder because c - d may well be negative.
Theorem 18. Let n be a prime divisor of N. If for some Lucas sequence {Uk}
for which (D/N) = - 1, TV|UN+, and
(21) (UF2,N)=l,
where r and s are defined by R2 = 2F2s + r, \r\ < F2, then TVis prime if and only if
s = Oorr2 4- 8s ¥=D .
Proof. The theorem will be proved in the equivalent form: TVis composite if and
only ifs^Oandr2 + 8s = D.
(i) (=*). Let n be a prime factor of TV,and write TV= nw, w > 1. Then from
Corollary 9, n = en (mod qF2), and since TV= - 1 (mod qF2), w = - en (mod qF2).
Then TV= (cF2 + e„)(dF2 - en), where c, d>B2. Also, F2 is odd and F2 is even, so
it follows that
en(d-c) = r (mod 2F2).
These together imply cd > ± en(d - c)B2 + B\. Now using (22),
(F2F2-l)[2F224-(52-r)F24-l]
Further, in the case that G = wFjF2 4- rFx 4- 1, assume (XFXF2 + rFx + \)^TV,
5q < X < m, where dr0 is the Kronecker delta. (Note: When r = 0 and m = 1, the X
interval is empty.)
//TV < G(BXB2FXF24- 1), then TVis prime.
Proof (by contradiction). Assume TVis composite, say TV= nw, n prime and
w > 1. Then Corollary 2 gives
(24) "-1 (mod pFj),
where q\R2, and w = wne„ = TVe„= (F2R2 - l)en = - en (mod qF2). Also,
where rFx 4- 1 < FjF2 4- 1, or more sharply, /Fj 4- 1 < FjF2 - 1, i.e., rFx 4- 1 is the
least positive remainder (mod FXF2).
Case 1.- en = 1. Combining (24) and (26) gives
n>pqFxF2 + 1 >BXB2FXF2 + 1.
Also, « s l (mod FjF2) from (28). Combining this with (27) gives w = nw = rFx +
1 (mod FjF2), which implies w > mFxF2 4- rFt 4- 1. On the other hand, w = - \
(mod qF2) implies
w>qF2 - 1 >£2F2 - 1.
These results with (25) give w > G. Thus finally, TV= wn > G(BXB2FXF24- 1), which
is a contradiction. Hence, TVis prime.
Case 2. en = — 1. This case is the same as Case 1 with the roles of n and w
reversed and (25) changed to read: n >BXFX 4- 1. Q.E.D.
Remarks. 1. In practice TV- 1 and TV4- 1 can be factored simultaneously; for
if a trial divisor d for TV4- 1 leaves a remainder t + 0, then d will divide TV- 1 if and
only if t = 2.
2. Usually Bx = B2 when the factoring of TV- 1 and TV4- 1 is done by the
method of Remark 1. These factoring bounds may be different, however, if the form
of TVpermits algebraic factorization, and the algebraic factors are investigated separately.
3. If the main inequality of the hypothesis is not satisfied at some point in the
factorization of TV± 1, there are three ways to increase the size of the product on the
right of the inequality: increase Bx and B2; find more factors of TV± 1 (thereby in-
creasing Fj or F2); increase the size of m. What strategy is adopted will, of course, de-
pend on the amount of increase needed to satisfy the inequality. An excellent example
of the use of this theorem will be found in the next section where the factorizations of
three Mersenne numbersMx61, Mxgi, and Af241 are shown to be complete. From
these examples, it becomes clear that none of the other hypotheses of Theorem 20 need
to be verified until the inequality on TVhas been satisfied, i.e., the auxiliary testing,
which is needed to complete the primality test, is done only after enough factoring data
have been obtained. (This, of course, is true for the other theorems in this paper.)
Thus, conditions (I)-(IV) are usually referred to as "final tests."
4. The special case when r = 0 occurs when F2 \RX, which implies F2 is odd.
Also, F21TV- 1, and since F2 |TV4- 1, then F2 12. Thus, F2 = 1. This case will occur
if and only if TV= 4k + 1 and TV4- 1 has no "small" odd prime factors.
Corollary 11. Assume (I)-(IV) and that the prime factors of both Rx and R2
are>B =BX = B2.
(a) // B > (N/F2F2)1 /3, then TVis prime.
(b) IfB> (N/FxF2y/3, then TVis prime.
Proof, (a) N<B3F2F2 <BFX(B2FXF2 4- 1) < G(B2FXF2 4- 1). (Note here
that only the first argument in the definition of G is used. Since the third argument in
this definition is not used at all in this theorem, no divisibility testing is needed in the
hypothesis of the corollary.)
(b) First observe in the proof of Theorem 20 that p and q are both > B, and
since p + q, pq> B(B 4- 2). Thus, the inequality following (28) can be written n >
B(B 4- 2)FjF2 4- 1. Consequently, when B = Bx = B2, the inequality in the theorem
can be strengthened to read TV< G[B(B + 2)FXF2 4- 1]. Then
TV< B3FXF¡ < (BF2 - 1) [B(B + 2)F,F2 4- 1]
{£/£')} is the sequence used for S¡ in (IV) and p¡(n) is the rank of« in {U^}, then by
Lemma 2, p¿(«)|TV 4- 1, but pi(n)-\'(N 4- 1)/S¡. Thus there is a prime divisor q. of S¡
which divides p((«) to S¡% full power in TV4- 1; i.e., q¡ '\p¡(n). But p.(n)\n — en , so
since(S,, S;) = 1, ITJ=1(¡rf'|n - e„. Also,
« = 1 (modft (/f'j,
so since (TV- 1,TV4- 1) = 2,
8. Numerical Results. The 131 complete factorizations given in Table 1 are the
results obtained by the authors over the last seven years on numbers of the form 2m
± 1, 22r ± 2r + 1, and 22'-1 ± 2r 4- 1 (see [4, p. 87]). (Note that factorizations of
both the primitive and algebraic parts of 2447 - 1 and 2471 — 1 appear in Table 1
and Section 9.)
In Table 1, all factors listed are prime. Those preceding a colon are algebraic;
those following a colon are primitive. An asterisk indicates the factor was first dis-
covered by R. M. Merson.
*Merson factor
*Merson factor
TABLE 1 (Continued)
55. 2li<7 + 274 + 1 = 13-113-1429-4981857697937 :
17059410504738323992180849
56. 2149 +1 = 3 : 1193-650833-38369587*
•7984559573504259856359124657
72. 2 5 + 2 3 + 1 = 13-41-61-2113-312709-415878438361 :
391249826881-13379250952 981
73. 2167 - 1 : 2349023-prime
74. 2 7 +1 = 3 : prime
75. 2168 - 2 + 1 = 433-38737 : l009-2ll69-2627857*-269389009
•1475204679190128571777
*Merson factor
TABLE 1 (Continued)
2174 + 2 "^ + 1 = 73 : prime
*Merson factor
TABLE 1 (Continued)
*Merson factor
TABLE 1 (Continued)
Character of
2,3,5,7,13,17,19,31,61,89,107,127 Prime
Table 2 shows which numbers of the above forms have been completely factored.
(Also from Table 2 it is not difficult to discover that 2 500 1,2 600 1,2700-1,
,816 1020 1 have been completely factored.) Table 3 gives the present
1, and 2
status of the "original" Mersenne numbers M = 2P — 1, p a prime < 257.
(The eight new factorizationsofMp are for p = 137, 139, 149, 157, 167, 197, 239,
and 241.)
Several different methods were used to complete the factorization of those num-
bers in Table 1 whose cofactors were composite. Notable examples are:
(i) The cofactors of 2139 - 1, 2205 4- 2103 4- 1, and 2255 4- 1 were factored
by a continued fraction method on the IBM 360/91 at the Campus Computing Net-
work at UCLA (see Morrison and Brillhart [13]). The times required for these factor-
izations were 80, 15, and 12 minutes respectively.
(Ü) 2101 4- 2S1 4- 1,2109 - 255 4- 1,2136 4- l,and 2137 4 1 were factored
by representing their composite cofactors as a difference of squares, using the delay-
line sieve DLS 127 at UC, Berkeley. (2136 4- 1 is particularly notable, having run on
DLS 127 for 2600 hours (!) before it factored.)
(hi) 2102 — 251 4- 1 was factored by expressing its cofactor as a sum of two
squares in two different ways on DLS 127.
(iv) 2131 4-2664- 1,2157- l,and2185 2 4-1 were completed on DLS
127 as in (ii) only after a new prime factor was found using idle time on the CDC 6400
at UC, Berkeley. Most surprising among these is the Mersenne number 2157 — 1,
which split unexpectedly into four factors.
Those numbers having a pseudoprime cofactor for some base a > 2 (see [4, p. 91])
were proved to be prime by some primality test (see Sections 2, 3, or 5). Of special
interest are the Mersenne numbers Mxbn, Mxgi, M239, and M24x, which were tested
using Corollary 11.
To illustrate the use of this corollary, the details for MX61 and M24X are given
here.
(a) Let
Department of Mathematics
University of Arizona
Tucson, Arizona 8S721
Department of Mathematics
University of California
Berkeley, California 94720
Department of Mathematics
Northern Illinois University
DeKalb, Illinois 60115