PRIMALITY TEST FOR FERMAT NUMBERS USING QUARTIC RECURRENCE EQUATION Predrag Terzic Podgorica, Montenegro pedja.terzic@hotmail.com Abstract. We present deterministic primality test for Fermat numbers, F n = n + 1, where n. Essentially this test is similar to the Lucas-Lehmer primality test for Mersenne numbers. 1. Introduction. Fermat numbers were first studied by Pierre de Fermat, who conjuctured that all Fermat numbers are prime. This conjecture was refuted by Leonhard Euler in 173 when he showed that F 5 is composite. It is known that F n is composite for 5 n 3. Question,are there infinitely many Fermat primes is still an open problem. In 1856 Edouard Lucas has developed primality test for Mersenne numbers. Test was improved by Lucas in 1878 and Derrick Lehmer in 1930 s. The test uses a sequence S i defined by S 0 = 4 and S i+1 = S i for i 1. Mersenne number M p is prime if and only if M p divides S p. In this paper we give primality test for Fermat numbers using quartic recurrsive equation : S i = S 4 i 1 4S i 1 +. The test uses a sequence defined by this recursion.. The test and Proof of correctness.1. The test. Let F n = n + 1 with n. In pseudocode the test might be written : //Determine if F n = n + 1 is prime FermatPrime(n) var S = 8 var F = n + 1 repeat n 1 1 times : S = (((S S) ) ((S S) ) ) (mod F ) if S = 0 return PRIME else return COMPOSITE Date: January 11, 01. 1
PREDRAG TERZIC.. Proof of correctness. Let us define sequence S i as : { 8 if i = 0; S i = (Si 1 ) otherwise. Theorem.1. F n = n + 1, (n ) is a prime if and only if F n divides S n 1 1. Proof. Let us define ω = 4 + 15 and ω = 4 15 and then define L n to be ω n + ω n, we get L 0 = ω + ω = 8, and L n+1 = ω n+ + ω n+ = (ω n+1 ) + ( ω n+1 ) = = (ω n+1 + ω n+1 ) ω n+1 ω n+1 = = ((ω n + ω n ) ω n ω n ) ω n+1 ω n+1 = = ((ω n + ω n ) (ω ω) n ) (ω ω) n+1 and since ω ω = 1 we get : L n+1 = (L n ) Because the L n satisfy the same inductive definition as the sequence S i, the two sequences must be the same. Proof of necessity : If n + 1 is prime then S n 1 1 is divisible by n + 1 We rely on simplification of the proof of Lucas-Lehmer test by Oystein J. R. Odseth, see [1].First notice that 3 is quadratic non-residue (mod F n ) and that 5 is quadratic non-residue (mod F n ). Euler s criterion then gives us : 3 Fn 1 1 (mod F n ) and 5 Fn 1 1 (mod F n ) On the other hand is a quadratic-residue (mod F n ), Euler s criterion gives: Fn 1 1 (mod F n ) Next define σ = 15, and define X as the multiplicative group of {a + b 15 a, b Z Fn }.We will use following lemmas : Lemma.1. : (x + y) Fn = x Fn + y Fn (mod F n ) Lemma.. : a Fn a (mod F n ) (Fermat little theorem) Then in group X we have : (6 + σ) Fn (6) Fn + (σ) Fn = 6 + ( 15) Fn
PRIMALITY TEST FOR FERMAT NUMBERS USING QUARTIC RECURRENCE EQUATION3 = 6 + Fn 15 Fn 1 15 = 6 + 3 Fn 1 5 Fn 1 15 = 6 + ( 1) ( 1) 15 = 6 + 15 (6 + σ) (mod F n ) We chose σ such that ω = (6+σ). We can use this to compute ω Fn 1 4 in the group X : ω Fn 1 = (6+σ)Fn 1 4 Fn 1 where we use fact that : = (6+σ)Fn (6+σ) 4 Fn 1 (6+σ) (6+σ) ( 1) (mod F n) = 1 (mod F n ) 4 Fn 1 = ( Fn 1 ) 3 (3 Fn 1 ) (1 3 ) ( 1) 1 (mod F n ) So we have shown that : ω Fn 1 1 (mod F n ) If we write this as ω n +1 1 = ω n 1 = ω n ω n 1 (mod F n ),multiply both sides by ω n, and put both terms on the left hand side to write this as : ω n + ω n 0 (mod F n ) ω (n 1 1) + ω (n 1 1) 0 (mod F n ) S n 1 1 0 (mod F n ) Since the left hand side is an integer this means therefore that S n 1 1 must be divisible by n + 1. Proof of sufficiency : If S n 1 1 is divisible by n + 1, then n + 1 is prime We rely on simplification of the proof of Lucas-Lehmer test by J. W. Bruce, see [].If n + 1 is not prime then it must be divisible by some prime factor F less than or equal to the square root of n + 1. From the hypothesis S n 1 1 is divisible by n + 1 so S n 1 1 is also multiple of F, so we can write : ω (n 1) + ω (n 1) = K F, for some integer K. We can write this equality as : ω n + ω n = K F Note that ω ω = 1 so we can multiply both sides by ω n and rewrite
4 PREDRAG TERZIC this relation as : ω n 1 = K F ω n 1. If we square both sides we get : ω n = (K F ω n 1) Now consider the set of numbers a + b 15 for integers a and b where a + b 15 and c + d 15 are considered equivalent if a and c differ by a multiple of F, and the same is true for b and d. There are F of these numbers, and addition and multiplication can be verified to be welldefined on sets of equivalent numbers. Given the element ω (considered as representative of an equivalence class), the associative law allows us to use exponential notation for repeated products : ω n = ω ω ω, where the product contains n factors and the usual rules for exponents can be justified. Consider the sequence of elements ω, ω, ω 3.... Because ω has the inverse ω every element in this sequence has an inverse. So there can be at most F 1 different elements of this sequence. Thus there must be at least two different exponents where ω j = ω k with j < k F. Multiply j times by inverse of ω to get that ω k j = 1 with 1 k j F 1. So we have proven that ω satisfies ω n = 1 for some positive exponent n less than or equal to F 1. Define the order of ω to be smallest positive integer d such that ω d = 1. So if n is any other positive integer satisfying ω n = 1 then n must be multiple of d. Write n = q d+r with r < d. Then if r 0 we have 1 = ω n = ω q d+r = (ω d ) q ωr = 1 q ωr = ω r contradicting the minimality of d so r = 0 and n is multiple of d. The relation ω n = (K F ω n 1) shows that ω n 1 (mod F ). So that n must be multiple of the order of ω. But the relation ω n 1 = K F ω n 1 shows that ω n 1 1 (mod F ) so the order cannot be any proper factor of n, therefore the order must be n. Since this order is less than or equal to F 1 and F is less or equal to the square root of n +1 we have relation : n F 1 n. This is true only if n = F 1 n + 1 = F. We will show that Fermat number cannot be square of prime factor. Theorem.. Any prime divisor p of F n = n + 1 is of the form k n+ + 1 whenever n is greater than one. Proof. For proof see [3] So prime factor F must be of the form k n+ + 1, therefore we can write : n + 1 = (k n+ + 1) n + 1 = k n+4 + k n+ + 1
PRIMALITY TEST FOR FERMAT NUMBERS USING QUARTIC RECURRENCE EQUATION5 n = k n+3 (k n+1 + 1) The last equality cannot be true since k n+1 + 1 is an odd number and n has no odd prime factors so n +1 F and therefore we have relation n < F 1 < n which is contradiction so therefore n + 1 must be prime. 3. Acknowledgments I wish to express my gratitude to Bojan Terzic for grammatical improvement of the text. References 1. Proof of necessity by Oystein J. R. Odseth available at : http : //en.wikipedia.org/wiki/lucas Lehmer primality test. Proof of sufficiency by J. W. Bruce available at : http : //www.mersennewiki.org/index.php/lucas Lehmer T est 3. Proof of Edouard Lucas theorem available at : http : //en.wikipedia.org/wiki/f ermat number