Prime Numbers: A Mathematical Mystery

In summary: Sure there are primalitry tests. To see if an integer n is prime, calculate \pi(n)-\pi(n-1). The result is 1 if an only if the number is prime.Beyond that, there is an algorithm based on Little Fermat's theorem that will either tell you that your number is composite or give you a very high probability that it's not.HallsofIvy's algorithm is more efficient, but the theorem-based algorithm is still accurate for very large values of n.
  • #1
.physics
15
0
Is there any mathematical formula to predict / generate / or test the prime number??
 
Physics news on Phys.org
  • #2
I'm not sure precisely what you mean, but the answer is probably yes.

However, algorithms are generally far easier to understand and efficient in practice than trying to compute an arithmetic formula.
 
  • #3
Certainly there exist a formula for testing form prime numbers:
To determine whether n is a prime number, divide it by every prime less than or equal to [itex]\sqrt{n}[/itex]. If none of those divides n, then n is prime.
 
  • #4
Sure there are primalitry tests. To see if an integer n is prime, calculate [itex]\pi(n)-\pi(n-1)[/itex]. The result is 1 if an only if the number is prime.
 
  • #5
CRGreathouse said:
Sure there are primalitry tests. To see if an integer n is prime, calculate [itex]\pi(n)-\pi(n-1)[/itex]. The result is 1 if an only if the number is prime.

but since the fastest algorithm to calculate [itex]\pi(n)[/itex] that, to my knowledge, has ever been actually implemented and tested, is O([itex]n^{2/3}[/itex] times some logs), you're better off doing what HallsofIvy proposes and trying to divide by all primes up to [itex]\sqrt{n}[/itex].

Beyond that, there is an algorithm based on Little Fermat's theorem that will either tell you that your number is composite or give you a very high probability that it's not.
 
  • #6
I suppose this means my example wasn't sufficiently over-the-top. New suggestion: to test if n is prime, test if sigma(n^2) = n^2 + n + 1.

hamster143 said:
you're better off doing what HallsofIvy proposes and trying to divide by all primes up to [itex]\sqrt{n}[/itex].

Far better would be APR-CL, and better than that would be ECPP. Eventually, AKS will be better than either, but that's not likely to happen soon or for small numbers.
 
  • #7
HallsofIvy said:
Certainly there exist a formula for testing form prime numbers:
To determine whether n is a prime number, divide it by every prime less than or equal to [itex]\sqrt{n}[/itex]. If none of those divides n, then n is prime.

This trial division method is certainly the easiest method; although it becomes difficult to compute for very large values of n. A similar variation on the trial division is to test whether n is a multiple of another integer m that is between 2 and the [tex]\sqrt{n}[/tex]. Obviously, if this is true than n is composite.
 
  • #8
Mersenne primes have been extensively studied, and some are generally among the largest primes known. The form is 2^p -1. p must be prime and in this case a factor of the number, if it exists, is of the form 2kp+1, and is +/- 1 Mod 8. This eliminates a whole lot of cases!

In fact in the case of 2^13-1 =8197, for 26k+1 to be of the form +/-1 Mod 8 , we have k=3 and k=4, giving 79 and 105the second case is eliminated since it contains 5 not of the form, while 79 can be shown not to work. Since the square root of 8191 is 90.5.., we need not try k=7 or higher, SO 2^13-1 IS A MERSENNE PRIME.
 

1. What are prime numbers?

Prime numbers are numbers that are only divisible by 1 and themselves. They are the building blocks of all other numbers and cannot be broken down into smaller whole numbers.

2. How are prime numbers used in mathematics?

Prime numbers are used in a variety of mathematical fields, including cryptography, number theory, and computer science. They are also used in the calculation of logarithms and in the creation of pseudo-random numbers.

3. How many prime numbers are there?

There are an infinite number of prime numbers, as they continue on without end. However, the largest known prime number as of 2021 is 2^82,589,933 - 1, which has over 24 million digits.

4. What is the importance of prime numbers?

Prime numbers are important in many areas of mathematics, including encryption, number theory, and algorithms. They also have real-world applications in fields such as computer security and banking.

5. What is the oldest known reference to prime numbers?

The oldest known reference to prime numbers dates back to ancient Greek mathematicians, including Euclid and Pythagoras. They were interested in prime numbers because of their mathematical properties and believed they held a special significance.

Similar threads

  • Linear and Abstract Algebra
Replies
2
Views
802
  • Linear and Abstract Algebra
Replies
9
Views
2K
Replies
5
Views
416
  • Set Theory, Logic, Probability, Statistics
Replies
17
Views
468
Replies
8
Views
372
  • Programming and Computer Science
Replies
22
Views
757
  • Linear and Abstract Algebra
Replies
11
Views
1K
  • General Math
Replies
17
Views
563
  • Precalculus Mathematics Homework Help
Replies
16
Views
2K
  • Linear and Abstract Algebra
Replies
4
Views
1K
Back
Top