Fermat's Test for Prime Numbers and Pseudo Primes: Explained

  • Thread starter MathematicalPhysicist
  • Start date
  • Tags
    Test
In summary, the conversation discusses the concept of Fermat's test for checking prime numbers and how it can be "fooled" by pseudoprime numbers. However, it is possible to efficiently check for pseudoprimes by only checking values of a that are less than p, thanks to the concept of modulo arithmetic.
  • #1
MathematicalPhysicist
Gold Member
4,699
371
i read the book "the man who loved only numbers" by paul hoffman, and there is explanation about fermat's test for checking prime numbers which states: if n is prime then for every whole number a the number a^n-a is a multiple of n.
now my question is about a pseduo prime number which "fools" this test how could you find such a number, i mean you should check every a which is ofcourse infinite numbers how could you possibly know that n is pseduo prime number by not checking every a?

btw the smallest p.p number is 561.
 
Physics news on Phys.org
  • #2
The statement

ap - a is a multiple of p

is equivalent to

ap = a (modulo p)


So, by the virtue of modulo arithmetic, we only need to check values of a that are less than p.

There are probably much more efficient theoretical tests for pseudoprimes, but my number theory book is at work so I can't look them up.
 
  • #3
Originally posted by Hurkyl



So, by the virtue of modulo arithmetic, we only need to check values of a that are less than p.

why is it that?
 
  • #4
I'll presume it's obvious that px = 0 mod p.


Consider this:

(a+kp)b = ab + kpb = ab (mod p)

Letting b = (a+kp)i, you can prove by induction that

(a+kp)n = an for all n.
 
  • #5
Originally posted by Hurkyl
I'll presume it's obvious that px = 0 mod p.


Consider this:

(a+kp)b = ab + kpb = ab (mod p)

Letting b = (a+kp)i, you can prove by induction that

(a+kp)n = an for all n.
x is integer?
 
  • #6
Originally posted by Hurkyl


(a+kp)n = an for all n.
excuse my ignorance but how does this proove you only need to check values of a smaller than p?
 
  • #7
Because

ap = a (mod p)

iff

(a+kp)p = a+kp (mod p)


P.S. all those little p's are supposed to be exponents.
 
  • #8
still don't get it )-: how does it prooves a+kp<p?


sorry to bother you.
 
  • #9
It doesn't.

Once we've checked all values of a less than p, this theorem extends our results to any other value of a because any integer n can be written as m + pk for some integer m in [0, p).
 

1. What is Fermat's Test for Prime Numbers and Pseudo Primes?

Fermat's Test is a probabilistic algorithm used to determine if a given number is a prime number or a pseudo prime. It is based on Fermat's Little Theorem, which states that if p is a prime number, then apa (mod p) for any integer a. If this congruence holds true for a number n, then n is likely to be a prime number.

2. How does Fermat's Test work?

First, a random integer a is chosen between 2 and n - 1. Then, the congruence an-1 ≡ 1 (mod n) is checked. If the congruence holds true, n is likely to be a prime number. However, if the congruence does not hold true, n is definitely not a prime number. This process is repeated multiple times with different values of a to increase the confidence in the result.

3. What is the difference between a prime number and a pseudo prime?

A prime number is a positive integer that is only divisible by 1 and itself. A pseudo prime, also known as a Fermat pseudoprime, is a composite number that passes the Fermat's Test and appears to be a prime number. However, it is not a true prime number and can be factored into smaller prime numbers.

4. How accurate is Fermat's Test?

Fermat's Test is not a foolproof method for determining prime numbers. It can produce false positives, meaning a composite number may pass the test and appear to be a prime. The likelihood of this happening decreases as the number of iterations increases. However, there are some numbers known as Carmichael numbers that always pass Fermat's Test, making it less reliable for larger numbers.

5. Are there any other methods for determining prime numbers?

Yes, there are several other methods for determining prime numbers, such as the Sieve of Eratosthenes, the Lucas-Lehmer Test, and the AKS primality test. Each method has its own advantages and limitations, and they are often used in combination to determine the primality of a number.

Similar threads

  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Programming and Computer Science
Replies
14
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
3K
  • Linear and Abstract Algebra
Replies
8
Views
4K
  • Linear and Abstract Algebra
Replies
5
Views
3K
  • Linear and Abstract Algebra
Replies
21
Views
8K
  • Linear and Abstract Algebra
Replies
2
Views
2K
  • General Discussion
Replies
4
Views
2K
  • Linear and Abstract Algebra
Replies
2
Views
6K
  • Linear and Abstract Algebra
Replies
14
Views
5K
Back
Top