arXiv:2005.02327v5 [math.NT] 10 Apr 2021 nieLcsscnes fFra’ itetermwihpoie oin no provides which theorem little of Fermat’s factorization of converse Lucas’s Unlike with sdsusd eas rv e eea-ups rmlt etfor test primality general-purpose new conver a Lucas’s prove of also extension We possible a discussed. result, is this From integer. an et uheoti u ndtriigfrwihpstv neeso t of integers positive which for determining in require put is relation common effort greatest Much some test. of computation require not form et a efudi 1,[] 5,[] nti ae epoearltvl mo relatively a prove we paper this In [6]. [5], [3], integers [1], for in test found be can tests Definition. simplicity. its of because ai etrpr ubri opst rapoal rm.Tepre The prime. Fermat’s probable a as or such composite others is of number while factorization a certainty report among absolute test conve test with Rabin Lucas’s Lehmer prime Lucas as n is such test, A number tests Proth’s date. these test, to primality of up Pocklington Some centuries established; many been for bee have alike has integers mathematicians composite amateur from and primes distinguishing of problem The Introduction 1 tion then , a xeietldt ugssti euthlsfrhge oesof powers higher for holds result this suggests data experimental nyfiieymn emtpedpie fteform the of Fermat many finitely only eetees tssilpsil htteepedpie r infinite are pseudoprimes these that possible still it’s Nevertheless, p nti ae epoeasml n e lgn eut o ie pos given a For result; elegant yet and simple a prove we paper this In n integer and ustruhtepie.W loso htti euthlsfor holds result this that show also We primes. the through runs ∗ ewrs rmlt et,Fra suorms ua’ et P test, Lucas’s Pseudoprimes, Fermat tests, Primality Keywords: tsawl-nw eutta hr r nntl ayFra pseudo Fermat many infinitely are there that result well-known a It’s aeeeUniversity Makerere p tp and rmlt etta eursta nyasnl d rm div prime odd single a a We only given. that requires is that theorem test little primality Fermat’s of converse Lucas’s of rmlt etfritgr fteform the of integers for test primality ob mlmne.Cnrr otewl-nw eut There result: well-known base the any to to Contrary pseudoprimes implemented. be to oefrso integers. of forms some er okigo n11 hnh hwdta tsntnecess not it’s that showed result he This when of 1914 factors theorem. in little Fermat’s Pocklington of Henry converse Lucas’s as n | .Atog hsnwpiaiyts a iie plcto,i’ tl wort still it’s application, limited has test primality new this Although 1. + p n scle emtpedpiet h base the to Fermat a called is n17,EoadLcssoe hti ninteger an if that showed Lucas Edouard 1876, In k b − ( | n − φ o oeodprime odd some for 1 Let 1) > k ( n n rmlt fnmeso h form the of numbers of Primality /p n n od rmwihteotmzdts sddcduigpoete ft of properties using deduced is test optimized the which from holds ) − n b − 6≡ ,teeaefiieymn suormso h form the of pseudoprimes many finitely are there 3, hspprsosta fapstv integer positive a if that shows paper this , nodrt eemn if determine to order in 1 eapstv nee.If integer. positive a be fteform the of or 1 1(mod n 1i re odtrietepiaiyof primality the determine to order in +1 n o l rm divisors prime all for ) b nti ae epoetefiiueo emtpedpie in pseudoprimes Fermat of finitude the prove we paper this In ; ap rk tpe Philemon Stephen Ariko k p 1, + and pi 3 2021 13, April p < a ap b n n ( Abstract k n sacmoiepstv nee and integer positive composite a is spie nti ae eotmz Pocklington’s optimize we paper this In prime. is − where 1 + 1) , 1 /p k p ≥ 6≡ of b where 1 1(mod ap . n p − k sprime, is b 1, + then , 1 xsssc that such exists n srof isor s rv e general-purpose new a prove lso p then ) a osdrbyipoe by improved considerably was ∗ k n sa d rm.Ti etdoes test This prime. odd an is 1 = sapedpiet h base the to pseudoprime a is r nntl ayFermat many infinitely are p < a s fFra’ itetheorem, little Fermat’s of rse n r oko l h prime the all know to ary p n ymn oaybase any to many ly n hti,fragvninteger given a for is, That . eo emtsltl theorem little Fermat’s of se nPclntnsprimality Pocklington’s in d spie eutknown result a prime, is , − oeifraino these on information More . tesdtriewehra whether determine others k clntnsts,Factoriza- test, ocklington’s n ap ,t n base any to 2, fitrs oprofessional to interest of n efudfrtetest the for found be 1 ap 3, = , iu et eedo the on depend tests vious a rm atro the of factor prime a has me fpiaiytests primality of umber k tv integer itive n oiieinteger positive any i omtedivisibility the form his omto nteprime the on formation k k ≥ rmlt et Miller- test, Primality b oaybase any to 1 + rmst n base any to primes n 1 + a .A extension An 1. eecetprimality efficient re − 1 6= ≡ b m n − 1(mod 3 1 Substantial . yattention hy > b ≡ a eodrof order he hr are there , 1(mod > b n where 1 ) > b 1. n n 1. b b ) . . Definition. Let a and n be relatively prime integers. The order of a modulo n denoted by ordna is the least positive integer x such that ax 1(mod n). ≡ Theorem 1.1. Let a and n be relatively prime integers, then a positive integer x is a solution of the congruence ax 1(mod n) if and only if ord a x. In particular, ord a φ(n). ≡ n | n | Theorem 1.2 (Pocklington’s ). Suppose that n is a positive integer with n 1= F R where (F, R)=1 and F > R. The integer n is prime if there exists an integer b such− that (b(n−1)/q 1, n) whenever q is a prime with q F and bn−1 1(mod n). − | ≡ 2 Primes of the form ap + 1

In this section, we prove a primality test for integers of the form apk + 1 with k = 1. Later we will generalize this test for higher powers of p. Lemma 2.1. Let n = ap +1, where a is a positive integer and p is an odd prime. If p φ(n) then n = (sp + 1)(tp + 1) for some integer sp +1 and prime tp +1. |

a1 a2 ak Proof. Let n = p1 p2 pk be the factorization of n. We have φ(n) = a1−1 a2−1 ··· ak−1 p1 (p1 1) p2 (p2 1) pk (pk 1). The condition p φ(n) implies p = pi or p p 1 for− some i = 1, 2,−... ,···k. If p = p , then− p n ap = 1, which| is not possible. Hence | i − i | − p pi 1 for some i. Thus, pi = tp +1 for some integer t. Thus, n = mpi = m(tp +1) = ap +1. Factoring| − out p, we have p(a mt) = m 1, p m 1, m = sp + 1 for some integer s. Thus, − − | − n = mpi = (sp + 1)(tp + 1). This completes the proof. Remark. If n is odd and composite, we must have s 2, t 2. It follows that for all a< 4(p+1), we have p φ(n) if and only if n is prime. ≥ ≥ | Theorem 2.1. Let n = ap +1 where a is even and p is an odd prime with a< 4(p + 1). If there exists an integer b such that bn−1 1 (mod n) and ba 1(mod n) then n is prime. ≡ 6≡ Proof. We will show that if n is composite and bn−1 1(mod n) then ba 1(mod n). Assume n n−1 ≡ ≡ is composite and b 1(mod n). From Theorem 1.1, ordnb φ(n). Therefore if p ordnb we have p φ(n) and from≡ Lemma 2.1 we know n is prime, a contradiction| because n is| assumed | composite. Hence, we must have p ∤ ordnb, equivalently (ordnb, p) = 1. From Theorem 1.1, we a also note that ordnb n 1 = ap. Thus, ordnb a and from Theorem 1.1, b 1 (mod n). Consequently if bn−1 | 1(mod− n) and ba 1(mod |n), then we know n is prime. ≡ ≡ 6≡ Remark. A slightly more efficient primality test is obtained by replacing the hypothesis bn−1 1 (mod n) with b(n−1)/2 1 (mod n). ≡ ≡± Example 2.1. Suppose we want to test whether 547 = 42 13 + 1 is prime. Using fast modular techniques, it can be verified that 2546/2· 1(mod 547) and 242 475 1(mod 547) and from Theorem 2.1, 547 is prime. ≡ − ≡ 6≡ From Theorem 1.2, we note n = ba 1 is the largest integer n such that ba 1 (mod n), b> 1. Assume n>ba 1 or equivalently−p> (ba 1)/a . It follows that if p> (ba≡ 1)/a, then ba 1 (mod n). Furthermore− if bn−1 1 (mod n)− and p< (a 1)/4, from Theorem− 2.1 we know n is6≡ prime. We state this result as a corollary≡ − Corollary 2.1.1. Let n = ap +1 where a is even and p is an odd prime with p > max(a 1)/4, (ba 1)/a . If b> 1 is a positive integer and bn−1 1 (mod n) then n is prime.{ − − } ≡ Remark. It’s a well-known result that there are infinitely many Fermat pseudoprimes to any base b. However, Corollary 2.1.1 demonstrates that for a given positive integer a, there are only finitely many Fermat pseudoprimes of the form ap +1 to any base b> 1. Example 2.2. Taking b = 2 and a = 2, we compute (ba 2)/a = (22 2)/2 = 1. Assume p> 2, Corollary 2.1.1 tells us that if n = 2p +1 then 2n−1 −1 (mod n) if− and only if n is prime or equivalently p is a Sophie Germain prime if and only if 2≡2p 1 (mod 2p+1). If we take b = 2 and a = 6, we have (26 2)/6=31/3 < 11. Taking p 11 and ≡n =6p+1, we have 2n−1 1 (mod n) if and only if n is prime.− ≥ ≡ Lemma 2.1 can be extended to provide a primality test for any positive integer n with p n 1 for some odd prime p. From Lemma 2.1, we have p φ(n) if and only if n = (sp + 1)(tp +1)| − for some prime tp +1 and integer sp + 1. To prove that|p φ(n) if and only if n is prime, it suffices to show that sp +1 ∤ n for all s 1, sp +1 √n. | ≥ ≤

2 Theorem 2.2 (General purpose primality test). Let n 1= mp for some odd prime p. If sp+1 ∤ n for all integers 1 < sp +1 √n and there exists an− integer b such that bn−1 1 (mod n) and bm 1(mod n) then n is prime.≤ ≡ 6≡ Remark. Because of the trial divisions involved, Theorem 2.2 has limited application. It can only be implemented when the prime p is large enough such that there are a few integers sp +1 to check. Theorem 2.2 tells us that if n is a pseudoprime to the base b and bm 1(mod n) then n has a prime factor of the form tp + 1. This new primality test is a combination6≡ of modular exponentiation and trial division. Example 2.3. To test n = 700001 = 100000 7 + 1 for primality, we find that 2n−1 1 (mod n) and 2(n−1)/7 158306 1(mod n). To complete· the primality test, we verify that≡ 7s +1 ∤ n for all integers≡ 7s +1 6≡ √n = √700001 < 837 . Because n is odd, only the odd integers of the arithmetic progression≤ 7s + 1 may be considered. Note that s 119. We quickly find that 7s +1 ∤ n, s =2, 4,..., 118. Therefore, by Theorem 2.2 n is prime.≤

3 Generalization of Theorem 2.1 for higher powers of p

In this section we generalize the primality test presented in Theorem 2.1 for higher powers of p. Using a similar argument presented in the proof of Lemma 2.1, it can be shown that if n = apk +1, where a and k are positive integers, p is a prime with a

k b1 bj n = ap +1= Aq1 ... qj , where q1,..., qj are primes such that p qi 1 for i = 1,...,j and A consists of primes which are not congruent to 1 modulo p (if A> 1).| Since− pk φ (n), we have φ (n)= pkb for some b

pkAs s + other terms 1 ··· j

From the above expansion, we see that As1 sj ac ), so p s1 + + st. Since s1,...,st are all even (in aparticular at least 2), one≥ proves by induction| that s···+ + s s s with the 1 ··· t ≤ 1 ··· t base induction step being s1 + s2 s1s2 which holds since its equivalent to (s1 1)(s2 1) 1. Hence, p s + + s s s≤ a

3 Alternatively, we can make use of Pocklington’s primality test to show that 727 is prime. The steps required to show 727 is prime are exactly the same as in the optimized test except the additional gcd check required in Pocklington’s test. i.e. there’s need to further verify that (590, 727) = 1.

4 Generalization of Lemma 3.1 for am + 1 integers

Generalization of Lemma 3.1 will provide a relatively more efficient primality test for a broader set of positive integers. Substantial experimental data suggests that if n = am + 1, a of m. If a

Theorem 4.1. Let n = am +1, where a and m > 1 are relatively prime positive integers such that n is prime whenever m φ(n). If for each prime qi dividing m, there exists an integer bi − | − such that b n 1 1 (mod n) and b (n 1)/qi 1(mod n) then n is prime. i ≡ i 6≡ a1 a2 ak Proof. From Theorem 1.1, ordnbi n 1. Let m = q1 q2 qk be the prime power factor- | − − ··· ization of m. Again, from Theorem 1.1, b (n 1)/qi 1(mod n) implies ord b ∤ (n 1)/q . We i 6≡ n i − i leave to the reader to verify that the combination of ordnbi n 1 and ordnbi ∤ (n 1)/qi implies ai | − ai − qi ordnbi. From Theorem 1.1, ordnbi φ(n) therefore for each i, qi φ(n) hence m φ(n). Because| n is assumed prime whenever m | φ(n) , we conclude n is prime.| | | Theorem 4.1 has little practical value on its own but becomes powerful when the integer m is known beforehand. Assuming the truth of Conjecture 4.1, Theorem 4.1 is an optimized primality test for such integers. Theorem 4.2 (Extended Lucas’s converse of Fermat’s little theorem). Assume Conjecture 4.1 holds. Let n = am +1, where a and m are positive integers and let p be the least prime divisor of m, a

k si k ti Theorem 4.3. Let n 1= Q pi where pi are distinct primes, si 1. Let m = Q pi , − i=1 ≥ i=1 0 ti si be an integer such that n is prime whenever m φ(n). If for each prime pi dividing s −t +1 ≤ ≤ n−1 | (n−1)/(pi i i ) m, there exists an integer bi such that bi 1 (mod n) and bi 1(mod n) then n is prime. ≡ 6≡

si−(s −ti+1)+1 Proof. Using a similar argument as in the proof of Theorem 4.1, for each i, we have pi i = p ti φ(n) hence m φ(n). By the hypotheses of Theorem 4.3, n is prime. i | |

4 Remark. Theorem 4.3 is a strengthening of Theorem 4.1; It does not require that m and (n 1)/m − be relatively prime as required in Theorem 4.1. Taking si = ti for all i, we have Theorem 4.1. Theorem 4.3 is relatively more efficient than Theorem 4.1 when ti stp2 p p2 = p3, a contradiction because na is prime. If an integer b exists such that bn−1 1 (mod n) and ba 1 (mod n) then n is prime. ≡ 6≡ Proof. From Lemma 4.1, p φ(n) if and only if n is prime. Because the integer b satisfies the hypothesis of Theorem 4.3, n| is prime. Remark. Similar to Theorem 2.1, Theorem 4.4 allows us to deduce the simple unexpected result; For a given positive integer a, there are finitely many Fermat pseudoprimes of the form ap2 +1 to any base b > 1. In light of Theorem 4.4, this is true because ba 1 (mod n) for all n>ba. This in effect removes the need to further verify that (bap 1, n) =6≡ 1 as required in the more versatile Pocklington’s primality test. − Note that Theorem 4.3 is an open theorem; Just like Theorem 4.1, it can be used for any suitable choice of the positive integer m for which m φ(n) if and only if n is prime. The reader is welcome to investigate this property further. | Lemma 4.2. Let a be a positive integer that is not a perfect . The diophantine equation (xz + 1)(yz +1)= az3 +1 has no solutions in positive integers x, y, z with z>a2 +2a. Proof. The equation (xz + 1)(yz +1) = az3 + 1 can be rewritten as az2 xyz (x + y) = 0. We shall show that for any positive integer solution (x,y,z), we have z −a2 +2−a. Note that z x + y, therefore z x + y. If (x,y,z) is a solution, then ≤ | ≤ xy + px2y2 +4a(x + y) z = 2a In order for z to be rational, the discriminant must be a perfect square. Therefore w2 = x2y2 + 4a(x+y). We see that w >xy and w xy (mod 2). We can write w = xy+2t, t> 0. Substituting w above, (xy +2t)2 = x2y2 +4a(x +≡ y). Expanding and simplifying, txy ax ay + t2 = 0. Multiplying through by t and factoring, (tx a)(ty a) = a2 t3. We must− have− t a 1 otherwise RHS < 0 and LHS 0. Because a−is not a− perfect cube,− a2 t3 = 0. The remainder≤ − of the proof utilizes the result:≥ If ab = c where a,b,c = 0 are integers then− a6 + b c + 1 if c> 0 and a + b (c + 1) if c< 0. We now consider two cases;6 ≤ Case 1≤− : a2 t3 > 0 ; Using the result above on the factored equation, we have (tx a)+ (ty a) a2 t−3 +1 a2. Hence, z x + y (a2 +2a)/t a2 +2a − . − ≤ − ≤ ≤ ≤ ≤ Case 2 : a2 t3 < 0 ; As in case 1, we have (tx a) + (ty a) t3 a2 1 , x + y t2 (a2 2a + 1)−/ta2 +2a is prime. If an integer b exists such that bn−1 1 (mod n) and ba 1 (mod6 n) then n is prime. ≡ 6≡ Proof. From Lemma 2.1 and Lemma 4.2, we have p φ(n) if and only if n is prime. Because the integer b satisfies the hypothesis of Theorem 4.3, we| conclude that n is prime. Remark. We immediately deduce that for any positive integer a that is not a perfect cube, there are finitely many Fermat pseudoprimes of the form ap3 +1 to any base b> 1. Conclusion. In this paper we have proved that for every positive integer a, there are finitely many Fermat pseudoprimes of the form apk + 1, k =1, 2 to any base b> 1. We have also shown that this results holds for k = 3, a = m3. What other forms of integers do we have finitely many pseudoprimes? For a given positive6 integer a and integer k > 3, are there finitely many pseudoprimes of the form apk +1 to a given base b?

5 Acknowledgement.

I thank my former lecturer, Dr. Bamunoba Alex Samuel for the encouragement and discussions in . Am also grateful for the referee’s helpful comments and suggestions.

References

[1] Brillhart, J., Lehmer, D.H., and Selfridge, J. L., New primality criteria and factor- izations of 2m 1 , Mathematics of Computation, 1975. ± [2] Pocklington, Henry C., The determination of the prime or composite nature of large numbers by Fermat’s theorem (1914-1916). Proceedings of the Cambridge Philosophical Soci- ety. [3] Rosen, Kenneth H., ”Elementary Number Theory and its Applications, 6th edition.” Addison-Wesley, 2011 [4] Brillhart, John; Selfridge, J. L. (April 1975). Some factorizations of 2m 1 and related results.” Mathematics of Computation. ± [5] D.H. Lehmer (1927). Tests for primality by the converse of Fermat’s theorem. Bull. Amer.Math. Soc [6] Pratt, - V. Every prime has a succinct certificate. SIAM Journal on Computing, vol. 4, 1975.

College of Eng., Design, Art and Technology, Makerere university. Email: [email protected]

6