Why is 240+1 not a prime number using the Fermat primality test with base a = 2?

  • Thread starter Firepanda
  • Start date
  • Tags
    Test
In summary, using the Fermat test for the base a=2, we can show that 240+1 is not a prime number by noticing that the number has a factorization of 28+1, and since 28 is not a power of 2, 240+1 cannot be a prime number. We can also see this by considering the order of 2 in the group of numbers not equal to 0 mod p, where p=240+1, and realizing that the order must be a factor of 2n, where n=40, indicating that n is a power of 2. Since n is not a power of 2, 2p-1=1 mod p cannot hold and thus
  • #1
Firepanda
430
0
Use the Fermat test for the base a = 2 to show that 240+1 is not
a prime number.

so, attempting

2240 = 1 mod (240+1)

But what now? :/ unusually large modulo I am not use to, must be some trick to this?

Thanks
 
Physics news on Phys.org
  • #2
Another attempt:

using the above

2240 = 1 mod (240+1)

write 2240

as 264624

now: 26464524

and 264 = 0 mod (240+1)

according to my calculator,

so 2240 = 0 mod (240+1)

edit: wolfram mathworld disagrees with my calculator on 264 = 0 mod (240+1) so I guess this is wrong
edit again: it was pretty obvious my calculator was wrong actually as 240+1 is odd and 264 is even
 
Last edited:
  • #3
Firepanda said:
Use the Fermat test for the base a = 2 to show that 240+1 is not a prime number.

Do you not really want to show that 2240+1 is not a prime number?
 
  • #4
Martin Rattigan said:
Do you not really want to show that 2240+1 is not a prime number?

nope the question is for 240+1
 
  • #5
But isn't that pretty obvious? If 240+1 were a prime p then 2 would have order 80 in the nonzero multiplicative group, so 5 would have to divide p-1=240 (which is clearly not on).
 
  • #6
well it depends on how obvious you think that is :P

well i know how to show p cannot be prime using the miller-rabin test

but the question states to use fermats primality test, and that's what I'm stuck on

unless that shows it, but it looks like a pretty abstract method I've never had practise with
 
  • #7
OK then 240+1=(28)5+1. Try dividing that by (28)+1. What would the remainder be?
 
  • #8
If you do that it should become clear that the first test for a number 2n+1 to be prime is that n is a power of 2.
 
Last edited:
  • #9
Martin Rattigan said:
OK then 240+1=(28)5+1. Try dividing that by (28)+1. What would the remainder be?

I'm not following why we're doing that..

(28+1).25 -31 = 240+1

is what i think you're asking..
 
  • #10
Fermat's theorem tells you that, for example:

[tex]
2^{4}\equiv 1\left(\rm{mod} 5\right)
[/tex]

What does this imply for [itex]2^{40} \left(\rm{mod 5}\right)[/itex]?
 
  • #11
JSuarez said:
Fermat's theorem tells you that, for example:

[tex]
2^{4}\equiv 1\left(\rm{mod} 5\right)
[/tex]

What does this imply for [itex]2^{40} \left(\rm{mod 5}\right)[/itex]?

is congruent to 1 also
 
  • #12
Exactly. How could you use this to simplify your original congruence (the one from the Fermat test)? Could you use it to prove that 2240 falsifies the test?
 
  • #13
JSuarez said:
Exactly. How could you use this to simplify your original congruence (the one from the Fermat test)? Could you use it to prove that 2240 falsifies the test?

well I'm not too sure why we're working in mod 5 all of a sudden, it's part of the prime factorization of 40 is all i can see
 
  • #14
Sorry - had to disappear to bed last night.

What I asked was badly put.

Sometimes you can factorize numbers that are given by substituting numbers into a polynomial by factorizing the polynomial and then substituting the numbers.

So when I said try dividing (28)5+1 by 28+1, I was really hinting at factorizing x5+1.

When n is odd xn+1 factorizes as (x+1)(xn-1-xn-2+xn-3 ... +1). The first term in the right hand bracket gives you the xn you want in the answer when you multiply by the x from the first bracket, but you get an unwanted xn-1 when you multiply it by the 1. The second term cancels the first unwanted term when you multiply by the x, but gives you a new unwanted term -xn-2 and so on. Each term after the first in the right hand bracket cancels out the unwanted term you get from multiplying the previous term by x+1. That carries on till you get down to 1, when the "unwanted" term is actually exactly what you want i.e. the 1 from xn+1. This only works when n is odd because the signs in the second bracket alternate and for even n you finish up with a -1 at the end instead of 1.

Anyway if you replace x in x5+1=(x+1)(x4-x3+x2-x+1) by 28 this gives you an explicit factorization of 240+1.

If you think about the above process you should be able to see that you will always be able to factorize a number of the form 2n+1 if n has an odd factor. Which means 2n+1 has no chance of being prime unless n is a power of 2.

Another way of looking at it is to use the ideas behind the test you wanted to apply. If p is a prime number the numbers other than 0 mod p form a group under multiplication. If you have a prime p and p=2n+1 then the order of this group is 2n.

Because 2n+1=0 mod p

2n=-1 mod p

so

22n=1 mod p

which means that the order of 2 is a divisor of 2n larger than n. (Notice that none of the numbers 2, 22, ... 2n can be 1 mod p.) The order of 2 is thus 2n. But then 2n must be a factor of 2n, so again n must be a power of 2.

It is quicker in this case to check whether 40 is a power of 2 (no) than to go ahead with checking that 2p-1=1 mod p.
 
Last edited:

1. What is the Fermat primality test?

The Fermat primality test is a probabilistic algorithm used to determine if a given number is a prime number. It is based on Fermat's little theorem, which states that if p is a prime number, then for any integer a, a^(p-1) mod p = 1. Therefore, if we choose a random integer a and compute a^(p-1) mod p, and the result is not equal to 1, then p is definitely not a prime number. However, if the result is 1, then p is likely to be a prime number, but further testing is needed to confirm.

2. How does the Fermat primality test work?

The Fermat primality test involves choosing a random integer a, computing a^(p-1) mod p, and checking if the result is equal to 1. If it is, then the number is likely to be a prime number. However, if the result is not equal to 1, then the number is definitely not a prime number. This process is repeated with different values of a to increase the likelihood of correctly identifying a prime number.

3. How accurate is the Fermat primality test?

The Fermat primality test is a probabilistic algorithm, which means that it can give incorrect results with a small probability. The accuracy of the test depends on the number of times it is repeated with different values of a. With each iteration, the likelihood of correctly identifying a prime number increases. However, there is always a small chance of a false positive or false negative result.

4. What is the time complexity of the Fermat primality test?

The time complexity of the Fermat primality test is O(k log n), where k is the number of iterations and n is the number being tested. This makes it a relatively fast algorithm for determining if a number is prime. However, as the number of digits in n increases, the time taken to complete the test also increases.

5. What are the limitations of the Fermat primality test?

The Fermat primality test can only identify probable prime numbers. This means that there is a small chance of getting a false positive result, where a composite number is identified as prime. To reduce this chance, the test needs to be repeated with different values of a. Additionally, the test cannot be used to prove that a number is definitely prime. Further testing using other algorithms is needed to confirm the primality of a number.

Similar threads

  • Calculus and Beyond Homework Help
Replies
3
Views
539
  • Calculus and Beyond Homework Help
Replies
16
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
949
  • Calculus and Beyond Homework Help
Replies
3
Views
725
  • Calculus and Beyond Homework Help
Replies
16
Views
1K
Replies
1
Views
750
  • Calculus and Beyond Homework Help
Replies
2
Views
807
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
16
Views
1K
Back
Top