You are Here: Home >< Maths

# How to prove a number is prime (division method) watch

1. Do you divide by just 2,3,5 then 7 or do you have to go up to prime before the square root? For either why do you do this?
2. Up to the prime before the square root.

For example if you were to divide 143 only by 2, 3, 5 and 7, you wouldn't see that 143 is in fact divisible by 11 and 13 and so is not a prime.
3. Indeed, the simplest primality test is to check if your number divisible by any where

People have developed other tests but that's the one that everyone uses.
4. Wouldn't doing something like a Fermat's little thereom primality test be much more efficient for larger primes?

Posted from TSR Mobile
5. (Original post by TheOtherSide.)
Up to the prime before the square root.

For example if you were to divide 143 only by 2, 3, 5 and 7, you wouldn't see that 143 is in fact divisible by 11 and 13 and so is not a prime.
(Original post by Indeterminate)
Indeed, the simplest primality test is to check if your number divisible by any where

People have developed other tests but that's the one that everyone uses.

Thank you! Why is it up to the square root and not further?

(Original post by BobBobson)
Wouldn't doing something like a Fermat's little thereom primality test be much more efficient for larger primes?

Posted from TSR Mobile
Not sure I haven't come across it I'm a yr13 student
6. (Original post by swagmister)
Thank you! Why is it up to the square root and not further?
Observe that if is not prime, then it can be written as for some and

At least one of these must be otherwise
7. (Original post by Indeterminate)
Observe that if is not prime, then it can be written as for some and

At least one of these must be otherwise
Ah okay thanks!
8. (Original post by Indeterminate)
Indeed, the simplest primality test is to check if your number divisible by any where

People have developed other tests but that's the one that everyone uses.
Well, not really. Almost anyone using this approach is actually going to check "is n divisible by 2?". If not, check for every odd m with , which is half the work.

Of course, this method is hopeless for primality checkijng of large primes.

(Original post by BobBobson)
Wouldn't doing something like a Fermat's little thereom primality test be much more efficient for larger primes?
Unfortunately, this doesn't work; there are numbers that pass Flt for all bases but are not prime. https://en.wikipedia.org/wiki/Carmichael_number

A somewhat related test that does "work" is Miller-Rabin. This gives absolute proof if tested with enough bases, with computational complexity O((log n)^4) (assuming Generalized Riemann Hypothesis). But for a composite number C, each test to a random base has at least (3/4) chance (*) of showing C is composite, and so the chance of C passing n tests is (3/4)^n. So in practice doing 50 or so tests on C gives you a scenario where if it somehow turned out C was composite, it's more likely something is wrong with the computer than that the tests have failed.

(*) in practice it's a lot higher. Using the first 6 primes as test-bases is enough to exclude all non-pirmes under 3 trillion.

Quite recently, an unconditional polynomial time (i.e. polynomial in number of digits of n) algorithm was found (known as the AKS primality test; the initial implementation was O((log n)^12 and this has been improved to O((log n)^6).

In practice I think people use Miller-Rabin variants for finding primes for RSA encryption et. al.

There are also specialised tests for numbers of particular forms, this is why we're able to find Mersenne primes (of form 2^n - 1) with much greater efficiency than general primes of similar size.

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: January 31, 2017
Today on TSR

### Congratulations to Harry and Meghan!

But did you bother to watch?

Poll
Useful resources

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams