.physics
- 15
- 0
Is there any mathematical formula to predict / generate / or test the prime number??
CRGreathouse said: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.
hamster143 said:you're better off doing what HallsofIvy proposes and trying to divide by all primes up to \sqrt{n}.
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 \sqrt{n}. If none of those divides n, then n is prime.